How to convert current date to epoch timestamp?

前端 未结 9 2287
情话喂你
情话喂你 2020-12-14 05:41

How to convert current date to epoch timestamp ?

Format current date:

29.08.2011 11:05:02
9条回答
  •  时光说笑
    2020-12-14 06:01

    That should do it

    import time
    
    date_time = '29.08.2011 11:05:02'
    pattern = '%d.%m.%Y %H:%M:%S'
    epoch = int(time.mktime(time.strptime(date_time, pattern)))
    print epoch
    

提交回复
热议问题