Reputation: 3
I have two date time string in this format
2019-07-09T19:42:19,002Z
2019-07-09T12:42:19,000-0700
and I need to convert these two date time strings into this format
2019-07-09T19:42:19.002+00:00
2019-07-09T12:42:19.000-07:00
I've tried
dt = parser.parse(dateTime)
ldt = parser.parse(localDateTime)
but that gives me this
dt = 2019-07-09 19:42:19.002000+00:00
ldt = 2019-07-09 12:42:19-07:00
Which doesn't include the "T" in both. And the milliseconds needs to be truncated to three digits in dt.
For reference the first 2 date time values adhere to ISO 8601 and I need it to adhere to RFC 3339.
from dateutil import parser
dateTime = '2019-07-09T19:42:19,002Z'
localDateTime = '2019-07-09T12:42:19,000-0700'
dt = parser.parse(dateTime)
ldt = parser.parse(localDateTime)
Upvotes: 0
Views: 65