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)?
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)?
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)
In Python 2.x you can do
import datetime
ms = [{u'date': u'1416143072400'}]
timestamp = int(ms[0]['date'])/1000
date = datetime.datetime.fromtimestamp(timestamp)
print date.strftime('%d/%m/%Y')
# 16/11/2014
but I don't know whether datetime
is available in SL4A