Date & Time
Date and time expressions use the JSONata Date/Time functions to return various formats of date/time, date, or time. These expressions are used to get the current timestamp in ISO 8601 formatted string, use an expression over the timestamp to convert the timestamp into a specific format.
Result | Expression |
Current timestamp as ISO 8601 | =$now() |
Current datetime in milliseconds | =$toMillis($now()) |
Current date [M]/[D]/[Y] | =$fromMillis($toMillis($now()), '[M]/[D]/[Y]') |
Current date [M01]/[D01]/[Y0001] | =$fromMillis($toMillis($now()), '[M01]/[D01]/[Y0001]') |
Current datetime '[M01]/[D01]/[Y0001] [H01]:[m01]:[s01]' | =$fromMillis($toMillis($now()), '[M01]/[D01]/[Y0001] [H01]:[m01]:[s01]') |
Current date [MI]/[DI]/[YI] | =$fromMillis($toMillis($now()), '[MI]/[DI]/[YI]') |
Current date [D1o] [MNn] [Y] | =$fromMillis($toMillis($now()), '[D1o] [MNn] [Y]') |
Current day | =$fromMillis($toMillis($now()), '[FNn]') |
Current time | =$fromMillis($toMillis($now()), '[H01]:[m01]:[s01]') |
Current time am/pm | =$fromMillis($toMillis($now()), '[h#1]:[m01][P]') |
Current time '[H01]:[m01]:[s01] [z]', '-0500' | =$fromMillis($toMillis($now()), '[H01]:[m01]:[s01] [z]', '-0500') |
Convert UTC to milliseconds | =$toMillis() |
Convert millisecond to UTC | =$fromMillis() |
This example uses a component.enitity to show the results of various date/time functions
See the full code sample in GitHub.