Dates
The date formatting feature uses the go date formatting, as such the same format layouts are
expected. Check https://gosamples.dev/date-time-format-cheatsheet/ for information on how the form
the formats. Default format 2006-01-02T15:04:05Z07:00.
Some dt prefixed functions returns timeObject, which is golang struct. This struct may be used
while calling multiple functions in a pipe, check examples for how-to-use tips.
All timeObject related functions description could be found on the official golang documentation
portal. Check all functions that starts from func (t Time).
Time related account configuration variables
Almost every account have default time related configurations, like timezone and formats. Timezone may not exist for accounts that shares many timezones (e.g. most of the USA accounts), in this case timezone should be configured by account owners.
Available variables:
Duration formatting syntax
The duration formatting feature partially inherits the go time formatting, so those are placeholders:
00- years01- months02- days03- hours04- minutes05- seconds
Sample usage:
| Name | Description | Function arguments | Usage |
|---|---|---|---|
| unixToDate | Convert a unix value to the requested date format in the selected timezone | unixToDate(unix, timeZone, format) string | {{ unixToDate 150000 “UTC” “2006-01-02” }} |
| formatDate | Convert one specific date format to another | formatDate(dateValue, fromFormat, toFormat, timeZone) string | {{ formatDate “2022-11-11” “2006-01-02” “2006/02/01” “GMT” }} |
| serverTime | Returns unix time in seconds | serverTime() int64 | {{ serverTime }} |
| serverTimeIn | Returns current datetime in provided timezone and format | serverTimeIn(timeZone, format) string | {{ serverTimeIn “GMT” “2006-01-02” }} |
| addDate | Adds amount of unitOfTime to the datetime and returns datetime in default format | addDate(datetime, unitOfTime, amount) string | {{ addDate “2023-01-02” “month” -6 }} |
| addDate | same as previous, but with optional format parameter | addDate(datetime, unitOfTime, amount, format) string | {{ addDate “2023-01-02” “month” 6 “2006/02/01” }} |
| dtFromDateTime | To get timeObject from the datetime | dtFromDateTime(datetime, format, timezone) timeObject | {{ dtFromDateTime “2023-01-02” “2006-01-02” “GMT” }} |
| dtCurrent | Current time (returns default format) | dtCurrent() timeObject | {{ dtCurrent }} |
| dtCurrentIn | Current time in TZ (returns default format) | dtCurrentIn(timezone) timeObject | {{ dtCurrentIn “GMT” }} |
| dtAdjustDate | add or subtract unit of time to/from datetime | dtAdjustDate(timeObject, unitOfTime, amount) timeObject | {{ dtAdjustDate timeObject “month” 6}} |
| dtFirstDayOfWeek | First day of week, if isSunday true then week starts from Sunday | dtFirstDayOfWeek(timeObject, isSunday) timeObject | {{ dtFirstDayOfWeek timeObject false }} |
| dtLastDayOfWeek | Last day of week, if isSunday true then week starts from Sunday | dtLastDayOfWeek(timeObject, isSunday) timeObject | {{ dtLastDayOfWeek timeObject false }} |
| dtFirstDayOfMonth | First day of month | dtFirstDayOfMonth(timeObject) timeObject | {{ dtFirstDayOfMonth timeObject }} |
| dtLastDayOfMonth | Last day of month | dtLastDayOfMonth(timeObject) timeObject | {{ dtLastDayOfMonth timeObject }} |
| dtFirstDayOfYear | First day of the year | dtFirstDayOfYear(timeObject) timeObject | {{ dtFirstDayOfYear timeObject }} |
| dtLastDayOfYear | Last day of the year | dtLastDayOfYear(timeObject) timeObject | {{ dtLastDayOfYear timeObject }} |
| dtToFormat | Convert timeObject to string using format | dtToFormat(timeObject, format) string | {{ dtToFormat timeObject “2006/02/01” }} |
| dtToTimezone | Set timeObject into a different timezone | dtToTimezone(timeObject, timezone) timeObject | {{ dtToTimezone timeObject “UTC” }} |
| dtToFormatIn | Set timezone and format at the same time | dtToFormatIn(timeObject, format, timezone) string | {{ dtToFormatIn timeObject “2006/02/01” “UTC” } |
| dtFirstDayOfPreviousMonthInFormat | Datetime manipulation in format, returns string | dtFirstDayOfPreviousMonthInFormat(timeObject, format) string | {{ dtFirstDayOfPreviousMonthInFormat timeObject “2006/02/01” }} |
| dtFirstDayOfCurrentMonthInFormat | Datetime manipulation in format, returns string | dtFirstDayOfCurrentMonthInFormat(timeObject, format) string | {{ dtFirstDayOfCurrentMonthInFormat timeObject “2006/02/01” }} |
| dtFirstDayOfNextMonthInFormat | Datetime manipulation in format, returns string | dtFirstDayOfNextMonthInFormat(timeObject, format) string | {{ dtFirstDayOfNextMonthInFormat timeObject “2006/02/01” }} |
| dtLastDayOfPreviousMonthInFormat | Datetime manipulation in format, returns string | dtLastDayOfPreviousMonthInFormat(timeObject, format) string | {{ dtLastDayOfPreviousMonthInFormat timeObject “2006/02/01” }} |
| dtLastDayOfCurrentMonthInFormat | Datetime manipulation in format, returns string | dtLastDayOfCurrentMonthInFormat(timeObject, format) string | {{ dtLastDayOfCurrentMonthInFormat timeObject “2006/02/01” }} |
| dtLastDayOfNextMonthInFormat | Datetime manipulation in format, returns string | dtLastDayOfNextMonthInFormat(timeObject, format) string | {{ dtLastDayOfNextMonthInFormat timeObject “2006/02/01” }} |
| dtFirstDayOfPreviousYearInFormat | Datetime manipulation in format, returns string | dtFirstDayOfPreviousYearInFormat(timeObject, format) string | {{ dtFirstDayOfPreviousYearInFormat timeObject “2006/02/01” }} |
| dtFirstDayOfCurrentYearInFormat | Datetime manipulation in format, returns string | dtFirstDayOfCurrentYearInFormat(timeObject, format) string | {{ dtFirstDayOfCurrentYearInFormat timeObject “2006/02/01” }} |
| dtFirstDayOfNextYearInFormat | Datetime manipulation in format, returns string | dtFirstDayOfNextYearInFormat(timeObject, format) string | {{ dtFirstDayOfNextYearInFormat timeObject “2006/02/01” }} |
| dtLastDayOfPreviousYearInFormat | Datetime manipulation in format, returns string | dtLastDayOfPreviousYearInFormat(timeObject, format) string | {{ dtLastDayOfPreviousYearInFormat timeObject “2006/02/01” }} |
| dtLastDayOfCurrentYearInFormat | Datetime manipulation in format, returns string | dtLastDayOfCurrentYearInFormat(timeObject, format) string | {{ dtLastDayOfCurrentYearInFormat timeObject “2006/02/01” }} |
| dtLastDayOfNextYearInFormat | Datetime manipulation in format, returns string | dtLastDayOfNextYearInFormat(timeObject, format) string | {{ dtLastDayOfNextYearInFormat timeObject “2006/02/01” }} |
| dtFuture | Datetime manipulation to get the nearest future quarter, half or full hour | dtFuture(timeObject, type) timeObject | {{ dtFuture timeObject “quarter” }} |
| dtStartOfDay | Datetime manipulation to get the start of the day time object | dtStartOfDay(timeObject) timeObject | {{ dtStartOfDay timeObject }} |
| dtEndOfDay | Datetime manipulation to get the end of the day time object | dtEndOfDay(timeObject) timeObject | {{ dtEndOfDay timeObject }} |
| dtNearestWeekday | returns nearest weekday of the timeObject. true - calculates in feature, otherwise in past | dtNearestWeekday(timeObject, weekday, false?) timeObject | {{ dtNearestWeekday timeObject, “Monday” }} |
| convertTimeUnits | Converts one time unit to another. Possible units: s, m, h. |
convertTimeUnits(amount, from, to) float64 | {{ convertTimeUnits 5 “h” “s” }} |
| parseDuration | Parses text formated duration to the time.Duration. Accepts value in format 2h45m35.5s |
parseDuration(dur) time.Duration | {{ parseDuration “245m” }} |
| parseDuration (roundTo) | parseDuration could also receive optional roundTo setting, which is one of s, m and h |
parseDuration(dur, roundTo) time.Duration | {{ parseDuration “245m35s” “m” }} |
| formatDuration | Formats passed duration to the specified format. Receives time.Duration or string types (check syntax) | formatDuration(dur, format) string | {{ formatDuration “245m” “05 sec” }} |
| formatDuration (roundTo) | formatDuration with optional roundTo param, which is one of s, m and h |
formatDuration(dur, format, roundTo) string | {{ formatDuration “245m22.6s” “05 sec” “s” }} |
| Unix | Its possible to get the unix value on any timeObject | timeObject.Unix | {{ $timeObject.Unix }} |