0

I have a date like this:

2022-12-29 11:47:07.444185+00:00

and I'm trying to format it. I tried this but I'm having an error:

utc = datetime.strptime(str(list(Rawdata.objects.filter(
                            id=r).values_list('created_at', flat=True))[0]), '%Y-%m-%d %H:%M:%S.%f %Z')


time data '2022-12-29 11:47:07.444185+00:00' does not match format '%Y-%m-%d %H:%M:%S.%f %Z'
2
  • there is no space between your microseconds and the timezone Commented Dec 29, 2022 at 12:57
  • why don't you just convert it to datetime object using datetime. Then you can do anything with it. What is your final goal? if you want to output it in specific format, you use strftime. Commented Dec 29, 2022 at 13:07

1 Answer 1

2

Update:

'%Y-%m-%d %H:%M:%S.%f %Z'

into

'%Y-%m-%d %H:%M:%S.%f%z'

More info on formats https://docs.python.org/3/library/time.html#time.strftime

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.