0

I want to convert a datestring into another date format.

The datestring

2014-11-20T00:00:00.000Z 

The code

datetime.datetime.strptime(date, '%Y-%m-%dT%H:%M:%S%Z').strftime('%Y%m%d') 

The error

time data '2014-11-20T00:00:00.000Z' does not match format '%Y-%m-%dT%H:%M:%S%Z' 

I can read the error message but I cannot find the right format that matches the datestring.

1 Answer 1

2

To include the millisecond paramater use this: datetime.datetime.strptime(d, '%Y-%m-%dT%H:%M:%S.%fZ').strftime('%Y%m%d')

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.