python - How I calculate the difference of two date time -
this question has answer here:
in database stored date time in following format. want difference between 2 samples in seconds. simple methods available?
u'2013-05-20 05:09:06' u'2013-05-20 05:10:06'
use datetime module.
>>> import datetime >>> start = datetime.datetime.strptime(u'2013-05-20 05:09:06', '%y-%m-%d %h:%m:%s') >>> end = datetime.datetime.strptime(u'2013-05-20 05:10:06', '%y-%m-%d %h:%m:%s') >>> (end - start).total_seconds() 60.0
Comments
Post a Comment