-
-
Save josepsmartinez/48e89ae63f66ea1b44cdb72650f352a7 to your computer and use it in GitHub Desktop.
Python datetime timestamps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
# ISO formatting | |
datetime.datetime.utcnow() # ('2022-05-10 04:18:09.297644') | |
datetime.datetime.now() # ('2022-05-10 01:18:09.297743') | |
# Custom formatting | |
## Pretty ('Saturday, 15. December 2012 11:19AM') | |
datetime.datetime.now().strftime("%A, %d. %B %Y %I:%M%p") | |
## Calendar ('2012-12-15') | |
datetime.datetime.now().strftime("%Y-%m-%d") | |
## Minimal string ('20220510011809297880') | |
datetime.datetime.now().strftime("%Y%m%d%H%M%S%f") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment