-
-
Save liquidgenius/c23c27032f023acf8e102f91be061c40 to your computer and use it in GitHub Desktop.
Python datetime / dateutil parsing dates example
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 | |
import dateutil.parser | |
timestring1 = '2007-03-04T21:08:12.127' | |
timestring2 = '2012-03-04 12:08:12.354' | |
dt1 = datetime.datetime.strptime(timestring1, '%Y-%m-%dT%H:%M:%S.%f') | |
dt2 = datetime.datetime.strptime(timestring2, '%Y-%m-%d %H:%M:%S.%f') | |
dup1 = dateutil.parser.parse(timestring1) | |
dup2 = dateutil.parser.parse(timestring2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment