What was midnight yesterday as an epoch time?

前端 未结 7 1358
太阳男子
太阳男子 2020-12-09 03:08

I\'m trying to get my head around the datetime module. I know the time now as an epoch and the time an event last happened (as an epoch time). What I need to do is figure

7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-09 03:48

    You can use this code:

    import time
    
    seconds_of_day = 24 * 60 * 60  # 86400
    last_midnight = (round(time.time()) // seconds_of_day) * seconds_of_day
    yesterday_last_midnight = last_midnight - seconds_of_day
    

提交回复
热议问题