Convert Unix Timestamp to human format in Django with Python

后端 未结 1 888
小鲜肉
小鲜肉 2021-02-09 06:23

I\'d like to a convert unix timestamp I have in a string (ex. 1277722499.82) into a more humanized format (hh:mm:ss or similar). Is there an easy way to do this in python for a

1条回答
  •  名媛妹妹
    2021-02-09 06:45

    >>> import datetime
    >>> datestring = "1277722499.82"
    
    >>> dt = datetime.datetime.fromtimestamp(float(datestring))
    >>> print dt
    2010-06-28 11:54:59.820000
    

    0 讨论(0)
提交回复
热议问题