Expressions

Date & Time

5min

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.

Configuration

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()

Consideration

  • When using =$now() on a component level, the date/time is not refreshed when navigating out and into the . To cater to this scenario, add an onFocus with a set-state action to the .
component
onFocus



Examples and code snippets 



Date & time expressions
Date & time expressions


This example uses a component.enitity to show the results of various date/time functions

See the full code sample in GitHub.

expression.jigx