1

Is there a python module/snippet which can decode the integer datestamps contained in OSX - specifically mail - plists?

EG, this bit:

<key>date-sent</key>    
<integer>1264001747</integer>

is likely in Jan 2010.

How to deconstruct? I'm aware of the very good plistlib - but this only gets me to that integer.

DrLou
  • 649
  • 5
  • 21

1 Answers1

1

You can use datetime.datetime.fromtimestamp

>>> import datetime
>>> datetime.datetime.fromtimestamp(1264001747)
datetime.datetime(2010, 1, 20, 10, 35, 47)

The value 1264001747 is the timestamp given in seconds from epoch. The returned datetime object is shown in the order (year, month, day, hour, minute, second)

Cory Kramer
  • 114,268
  • 16
  • 167
  • 218
  • Of course - and thanks for that. I was thrown off by other examples - perhaps even on SO? - which were dividing. Duh.Using the function straight up works perfectly. Thanks! – DrLou Jun 02 '15 at 21:53