This answer explains how to convert any given epoch to a non-localized datetime
.
This answer explains how to convert the epoch for right now to a human readable format for a pre-defined timezone.
This answer explains how to get the current system timezone, but not with pyzt
, which is used in the human readable format answer.
How do I convert any given epoch to a human readable format for the system timezone?
Convert from epoch to human-readable datemyString := DateTimeToStr(UnixToDateTime(Epoch)); Where Epoch is a signed integer. Replace 1526357743 with epoch. =(A1 / 86400) + 25569 Format the result cell for date/time, the result will be in GMT time (A1 is the cell with the epoch number).
To convert epoch dateTime to human readable , using a simple new date(1495159447834) will suffice.
Notice that UNIX Epoch is UTC so it identifies without errors a specific moment in time. Never ask about the timezone of a UNIX epoch timestamp, it is UTC by definition.
time.strftime
combined with time.localtime
should do the trick. The %Z
option will output the system timezone. For example:
>>> print time.strftime("%Z - %Y/%m/%d, %H:%M:%S", time.localtime(time.time()))
CDT - 2014/07/15, 13:32:19
Here, you can replace time.time()
with your chosen epoch.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With