How do I find the time difference between two datetime objects in python?

前端 未结 17 1013
無奈伤痛
無奈伤痛 2020-11-22 11:06

How do I tell the time difference in minutes between two datetime objects?

17条回答
  •  醉酒成梦
    2020-11-22 11:57

    This is how I get the number of hours that elapsed between two datetime.datetime objects:

    before = datetime.datetime.now()
    after  = datetime.datetime.now()
    hours  = math.floor(((after - before).seconds) / 3600)
    

提交回复
热议问题