The following functions are available.
Function Name | Arguments | Description | Example |
---|---|---|---|
Now |
Now([timezone]) | Returns the date and time type for the current date and time. | |
Year |
Year(t[, timezone]) | Returns the year of date and time type t . If timezone is specified, it is interpreted as the time zone. |
|
Month |
Month(t[, timezone]) | Returns the month of date and time type t . If timezone is specified, it is interpreted as the time zone. |
|
Day |
Day(t[, timezone]) | Returns a day of type t . If timezone is specified, it is interpreted as the time zone. |
|
Hour |
Hour(t[, timezone]) | Return the time of date and time type t . If timezone is specified, it is interpreted as the time zone. |
|
Minute |
Minute(t[, timezone]) | Return the minutes of date and time type t . If timezone is specified, it is interpreted as the time zone. |
|
Second |
Second(t[, timezone]) | Return seconds of date and time type t . If timezone is specified, it is interpreted as the time zone. |
|
Weekday |
Weekday(t[, timezone]) | Return the day of the week for date and time type t . If timezone is specified, it is interpreted as the time zone. (0 is Sunday.) |
|
ToLocal |
ToLocal(t) | Convert date and time type t to system time zone |
|
ToUTC |
ToUTC(t) | Convert date and time type t to UTC |
|
ToTimezone |
ToTimezone(t, timezone) | Converts a date and time type t to a specified time zone |
ToTimezone(Now(), "America/New_York") |
DateFormat |
DateFormat(t, layout) | Convert a date and time type t to a string with the specified layout. The key date that you can rearrange as you desire is 2006-01-02 15:04:05.999 MST with 01 representing the month, 02 representing the day, 15 representing the hours, 04 representing the minutes 05 representing the seconds, 2006 representing the year in four digits and 999 representing the microseconds. MST is the timezone (Mountain Standard Time). This is based on the GoLang date formatting standard, which you can look up here . |
Example to output the format Day Month Year Hour:Minute Timezone DateFormat(Now(), "02 Jan 06 15:04 MST") |
DateParse |
DateParse(layout, s[, timezone]) | Interprets s along the layout and returns a date/time type |
|
ToInt |
ToInt(timestamp) | Turn the timestamp into a unix timestamp | ToInt(cv.Payload.Timestamp) |
Example usage of the Now
function:
Gravio uses GoLang Date formatting. More details can be found in the GoLang date format source code file.
Need more help with this?
Join our slack community for help