converting 13-digit unixtime in ms to timestamp in python

后端 未结 2 1626
一个人的身影
一个人的身影 2021-01-12 18:53

I want to convert 13-digit Unix-time in milliseconds to the timestamp :

\"1523126888080\"==>> %Y-%m-%d %H:%M:%S

I have tried the following code from this lin

2条回答
  •  时光说笑
    2021-01-12 19:17

    Try dividing 1523126888080 by 1000 to get a valid timestamp.
    You should also use %d instead of %D as argument for strftime, i.e:

    import time
    ts = 1523126888080 / 1000
    print(time.strftime("%d %H:%M", time.localtime(ts)))
    # 29 21:04
    

提交回复
热议问题