2

I have a following datetime:

d1 = 2015-03-21 14:50:54.0.

While doing datetime.strptime(d1, "%Y-%m-%d %H:%M:%S") I get an error that ValueError: unconverted data remains: .0. How can I add milliseconds to the time? If it not possible then how can I remove milliseconds from d1?

0

1 Answer 1

2

Use %f to grab the milliseconds part of the time string:

>>> out = datetime.strptime(d1, "%Y-%m-%d %H:%M:%S.%f") 
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.