I have a time stamp in the format 20140110143000
I need to convert it into a human readble format.
I am using the following code:
time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(20140110143000))
But it is giving the following error:
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(20140110143000))
ValueError: (22, 'Invalid argument')
Can any body please help me out?
coincidentally datetime
objects prints timestamp in %Y-%m-%d %H:%M:%S
format. So, for printing 20140110143000
in required format you can simply convert it to a datetime object and print it
from datetime import datetime
print datetime.strptime("20140110143000", "%Y%m%d%H%M%S")
output
2014-01-10 14:30:00
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.