1

How to write regular expression that matches both datetime format 2015-01-13T16:12:04.000Z and date format 6/19/14?

1
  • You appear to have this confused with a regex-writing service; it really isn't. Also, you want strptime, not a regular expression. Commented Mar 22, 2015 at 20:59

1 Answer 1

2

You can parse dates like this:

from dateutil.parser import parse
d = parse("2015-01-13T16:12:04.000Z")

Now d is a datetime.datetime(2015, 1, 13, 16, 12, 4, tzinfo=tzutc()). This can be printed like

import datetime
print("{d.month}/{d.day}/{d.year}".format(d=datetime.datetime.now()))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.