Skip to content

Instantly share code, notes, and snippets.

@ycui1
Last active Jan 10, 2020
Embed
What would you like to do?
from datetime import datetime
datetime(2020, 1, 10, 13, 2, 0)
# a datetime object by specifying year, month, day, hour, minute, second
datetime.today()
# a datetime object with current date and time
datetime.now()
# the same as above when tz is None
datetime.utcnow()
# the same as above, but in the UTC (Coordinated Universal Time)
date_stamp = datetime.fromtimestamp(1578683037)
# a datetime object created using a POSIX timestamp
date_ordinal = datetime.fromordinal(734000)
# a datetime object created by specifying the number of days since year 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment