How to convert current date to epoch timestamp?

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

How to convert current date to epoch timestamp ?

Format current date:

29.08.2011 11:05:02
9条回答
  •  猫巷女王i
    2020-12-14 05:53

    if you want UTC try some of the gm functions:

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

提交回复
热议问题