Problem:
In the Chrome Dev Tools console, I'd like to view a Unix Time numerical value/timestamp as a human-readable UTC date/time string.
Solution:
In the Chrome Dev Tools console (and in general), one way to view a Unix (POSIX/Epoch) Time as a human-readable UTC string is to use Javascript Date.
For example, if the number of seconds since Epoch is 1480528272, we can convert this in the console by:
new Date(1480528272*1000).toUTCString()
Note that we need to convert the number of seconds to milliseconds since Epoch by multiplying by 1000.
Notes:
Note that due to the size of a Javascript integer, overflow may occur if the desired timestamp is larger than Number.MAX_SAFE_INTEGER.
A Javascript Date object also has a valid range that must be adhered to. More information can be found in here.
No comments:
Post a Comment