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

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -