Search code examples
pythondatesmssl4a

SL4A Python SMS Date Format


I am accessing my SMS messages with:

ms=droid.smsGetMessages(False, 'inbox', ['date']).result

The results are in the following format:

[{u'date': u'1416143072400'}]

How do I convert the date value to a readable format (dd/mm/yyyy)?


Solution

  • It looks like you're getting back seconds since the epoch times 1000..

    >>> import datetime
    >>> datetime.datetime.fromtimestamp(int(u'1416143072400')//1000)
    datetime.datetime(2014, 11, 16, 14, 4, 32)