Convert timestamp since epoch to datetime.datetime

后端 未结 3 1346
无人共我
无人共我 2020-11-30 05:08

I have the following timestamps since epoch:

Timestamp
1346114717972
1354087827000

How can I convert these timestamps to some specific outp

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-30 06:05

    This is the simplest method I've ever seen-

    $ python
    Python 2.7.5 (default, Nov  6 2016, 00:28:07) 
    [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import time
    >>> print(time.strftime('%Y-%m-%dT%H:%M:%S %Z',time.localtime(time.time())))
    2018-05-02T13:21:44 IST
    

提交回复
热议问题