EQL provides two functions to obtain the corresponding timestamp in different time zones.
TO_TZ
. Takes a timestamp in GMT, looks up the GMT offset for the specified time zone at that time in GMT, and returns a timestamp adjusted by that offset. If the specified time zone does not exist, the result is NULL.
For example, TO_TZ(dateTime,'America/New_York')
answers the question, "What time was it in America/New_York when it was dateTime
in GMT?"
FROM_TZ
. Takes a timestamp in the specified time zone, looks up the GMT offset for the specified time zone at that time, and returns a timestamp adjusted by that offset. If the specified time zone does not exist, the result is NULL.
For example, FROM_TZ(dateTime,'EST')
answers the question, "What time was it in GMT when it was dateTime
in EST?"
Expression | Results |
---|---|
TO_TZ(TO_DATETIME('2016-07-05T16:00:00.000Z'), 'America/New_York') |
2016-07-05T12:00:00.000Z |
TO_TZ(TO_DATETIME('2016-01-05T16:00:00.000Z'), 'America/New_York') |
2016-01-05T11:00:00.000Z |
FROM_TZ(TO_DATETIME('2016-07-05T16:00:00.000Z'), 'America/Los_Angeles') |
2016-07-05T23:00:00.000Z |
FROM_TZ(TO_DATETIME('2016-01-05T16:00:00.000Z'), 'America/Los_Angeles') |
2016-01-06T00:00:00.000Z |