Skip to main content

$fromMillis

$fromMillis(number?, picture?, timezone?) -> string
Compact type signature<n-s?s?:s>

If number is omitted, the current context value is used.

Browse categories

Source: JSONata

Documentation

Convert the number representing milliseconds since the Unix Epoch (1 January, 1970 UTC) to a formatted string representation of the timestamp as specified by the picture string.

If the optional picture parameter is omitted, then the timestamp is formatted in the ISO 8601 format.

If the optional picture string is supplied, then the timestamp is formatted occording to the representation specified in that string. The behaviour of this function is consistent with the two-argument version of the XPath/XQuery function fn:format-dateTime as defined in the XPath F&O 3.1 specification. The picture string parameter defines how the timestamp is formatted and has the same syntax as fn:format-dateTime.

If the optional timezone string is supplied, then the formatted timestamp will be in that timezone. The timezone string should be in the format "±HHMM", where ± is either the plus or minus sign and HHMM is the offset in hours and minutes from UTC. Positive offset for timezones east of UTC, negative offset for timezones west of UTC.

Examples

Basic usage

  • $fromMillis(1510067557121) => "2017-11-07T15:12:37.121Z"
  • $fromMillis(1510067557121, '[M01]/[D01]/[Y0001] [h#1]:[m01][P]') => "11/07/2017 3:12pm"
  • $fromMillis(1510067557121, '[H01]:[m01]:[s01] [z]', '-0500') => "10:12:37 GMT-05:00"

Convert epoch milliseconds back to an ISO 8601 timestamp

Input

1771061400000

Expression

$fromMillis($)

Result

"2026-02-14T09:30:00.000Z"