LoginSignup
46
34

More than 5 years have passed since last update.

pythonで日時の差分を秒単位で出す方法

Last updated at Posted at 2013-11-20

毎回ぐぐってるから書く。

import datetime

#year,month,day,hour,minute,second(,micro?)がdatetimeメソッドの引数
first_time = datetime.datetime(2013,11,10,11,11,11)
last_time =  datetime.datetime(2014,11,10,11,11,11)
delta = last_time - first_time
print delta.total_seconds()
#=>31536000.0 total_secondsを使って差を秒で表現
46
34
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
46
34