I am trying to convert Mac OSX (HFS Plus) timestamps to human readable format with python (on a linux system).
HFS Plus timestamps represent the time in seconds since midnight Jan 1, 1904.
For example, the timestamp: 3453120824
In human date time: Mon, 03 Jun 2013 16:13:44 GMT
Is there a python way to do this?
How about just using datetime with timedelta? You'll want to pay particular attention to the list of formatting characters here
>>> import datetime
>>> d = datetime.datetime.strptime("01-01-1904", "%m-%d-%Y")
>>> d
datetime.datetime(1904, 1, 1, 0, 0)
>>> d + datetime.timedelta(seconds=3453120824)
datetime.datetime(2013, 6, 3, 16, 13, 44)
>>> (d + datetime.timedelta(seconds=3453120824)).strftime("%a, %d %b %Y %H:%M:%S GMT")
'Mon, 03 Jun 2013 16:13:44 GMT'
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