0

I have a function in my backend and I receive the date from the front end in the formart Wed Dec 14 2016 14:39:16 GMT+0300 (AST)

date = request.body['date']
d = datetime.strptime(date, '%a %b %d %Y %X %Z%z')

I know strptime converts to the datetime object but I keep getting the following

'z' is a bad directive in format '%a %b %d %Y %X %Z%z'

What should my string format be?

Ysrninja
  • 129
  • 1
  • 2
  • 9

1 Answers1

0

You can do like this:

from dateutil import parser
parser.parse("Wed Dec 14 2016 14:39:16 GMT+0300 (AST)")
Adilet Maratov
  • 1,312
  • 2
  • 14
  • 24