Convert UNIX Time/EPOCH Time

Copper Contributor

Is there a way to convert time in UNIX/EPOCH to a readable time format? I have the attached data collected and would like to be able to convert it.

 

Thanks,

Sean

 

1 Reply

Hi,

 

That's possible, using standard datetime calculations, but do note that the language recommendation for datetime datatype is to use SO 8601 format, and any conversion you make is your responsibility.

Based on the naive assumption that unix epoch time is the number of seconds since 1970, here's an example of how to convert it time to UTC:

 

let unix_epoch_time = 1544143119;
print UTC_time = datetime('1970-01-01T00:00:00Z') + unix_epoch_time*1s

 

Referring to use your attachment, 1544143119 would be: 2018-12-07T00:38:39.000, which is more readable.

Converting the other way around would be:

 

print calculated_unix_epoch_time = (datetime('2004-09-16T17:55:43.54Z')-datetime('1970-01-01T00:00:00Z'))/1s

 

Note it does not take into account leap seconds (explained here).

 

HTH,

Noa