formatTime() Query Function

Formats a string according to strftime, similar to unix strftime. See Java documentation for valid Date/Time valid escapes

Parameters

Name

Type

Required

Default

Description

format

string

Yes

Format string. See Java documentation for valid Date/Time valid escapes.

field

string

No

@timestamp

Where to get the current time.

as

string

Yes

Specifies the output field.

locale

string

No

Specifies the locale such as US or en_GB.

timezone

string

No

Specifies the timezone such as GMT, EST or Europe/London. See the full list of supported timezones.

The implied parameter is format.

Examples

Format time as 2021/11/26 06:54:45 using the timestmp field and UTC timezone using assignment to fmttime:

humio
time := formatTime("%Y/%m/%d %H:%M:%S", field=@timestamp, locale=en_US, timezone=Z)

Format time as Thursday 18 November 2021, 22:59 using US locale and PST timezone using the as parameter to fmttime

humio
formattime("%A %d %B %Y, %R", as=fmttime, field=@timestamp, timezone=PST)