Answers for "linux timestamp to date python"

3

unix to date python

>>> from datetime import datetime
>>> ts = int("1284101485")

# if you encounter a "year is out of range" error the timestamp
# may be in milliseconds, try `ts /= 1000` in that case
>>> print(datetime.utcfromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S'))
#'%Y' will be replaced by the year '%m' by the month '%d; by the day and so on 
#You move these how you want in the string, other characters will be ignored!
... '2010-09-10 06:51:25'
Posted by: Guest on March-25-2021
9

timestamp to date python

from datetime import datetime

timestamp = 1586507536367
dt_object = datetime.fromtimestamp(timestamp)
Posted by: Guest on April-10-2020

Code answers related to "linux timestamp to date python"

Python Answers by Framework

Browse Popular Code Answers by Language