I want to convert from a format like 2015-12-09 12:40:08
(it seems to be ISO format) to datetime.
Reference http://qiita.com/shibainurou/items/0b0f8b0233c45fc163cd
I implemented it as follows.
http://ideone.com/IaAbuS
from datetime import datetime as dt
strdt1 = "2015-12-09 12:40:08"
strdt2 = "2015-12-09 12:35:08"
tdt1 = dt.strptime(strdt1, "%Y-%m-%d %H:%M:%S")
tdt2 = dt.strptime(strdt2, "%Y-%m-%d %H:%M:%S")
print tdt1
print tdt2
print tdt1 - tdt2
result
Success time: 0.02 memory: 9184 signal:0
2015-12-09 12:40:08
2015-12-09 12:35:08
0:05:00
Recommended Posts