TIMEX
TIMEX

Reputation: 271774

How do I turn this date into a python datetime object?

I want a datetime object, but I have strings in this format:

2010-10-06T08:12:41Z

How do I turn that into a datetime object?

Upvotes: 2

Views: 221

Answers (2)

Kasapo
Kasapo

Reputation: 5374

import datetime
datetime.datetime.strptime("2010-10-06T08:12:41Z", "%Y-%m-%dT%H:%M:%SZ")

Upvotes: 2

knitti
knitti

Reputation: 7033

from datetime import datetime
print datetime.strptime(timestring, '%Y-%m-%dT%H:%M:%SZ')

it's in the docs

Upvotes: 6

Related Questions