Date Epoch Example

An epoch date is either the number of seconds or milliseconds since 1 January 1970 00:00:00 UTC. UNIX and other applications use seconds, while JavaScript uses milliseconds. SnapLogic uses JavaScript as its scripting language, so the epoch date is internally stored as milliseconds since epoch.

In the example below, we are passing in the date in seconds since epoch.

1 - Set a project parameter. In my example, I have “dateEpoch” set to 1472799302.
2 - Use the following formula in a mapper snap:
Date.parse(Date.parse(1000*_dateEpoch).toString()).toLocaleDateTimeString(’{“timeZone”:“America/Chicago”, “format”:“MM-dd-yyyy HH:mm:ss”}’)

This returns a value of: 09-02-2016 01:55:02

Further examples:

Date.parse(1000*_dateEpoch) = “2016-09-02T06:55:02.000 Etc/UTC”

Date.parse(1000*_dateEpoch).toString() = “2016-09-02T06:55:02.000Z”

date test epoch_2017_02_28.slp (4.6 KB)