I have string time in the following format
2016-12-10T13:54:15.294
I am using the following method to format the time:
time.strptime(
Your format string is not correct.
You can check format string just using strftime method of date object. For example:
d = datetime.datetime.now()
print(d.strftime('%Y-%d-%mT%H:%M:%S'))
Output:
Dec 16 11:02:46 2016
But you have string in following format 2016-12-10T13:54:15.294
, so you just need to change format string:
print(time.strptime(ts, '%Y-%d-%mT%H:%M:%S.%f'))
output:
time.struct_time(tm_year=2016, tm_mon=10, tm_mday=12, tm_hour=13, tm_min=54, tm_sec=15, tm_wday=2, tm_yday=286, tm_isdst=-1)