Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert any epoch to human readable format for system timezone

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?

like image 738
Chris Redford Avatar asked Jul 15 '14 18:07

Chris Redford


People also ask

How do you convert epoch time to human readable?

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).

How do you convert epoch time to human readable in react JS?

To convert epoch dateTime to human readable , using a simple new date(1495159447834) will suffice.

What timezone does epoch use?

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.


1 Answers

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.

like image 137
TheSoundDefense Avatar answered Sep 30 '22 09:09

TheSoundDefense