Skip to content

Instantly share code, notes, and snippets.

@ycui1
Last active January 10, 2020 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ycui1/84d73606750a3713ec23e8ec944e32d9 to your computer and use it in GitHub Desktop.
Save ycui1/84d73606750a3713ec23e8ec944e32d9 to your computer and use it in GitHub Desktop.
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