1

I'm trying to format the date of an email using python2.7. The value of date is like

Date: "Tue, 9 Apr 2019 11:49:26 -0400"

Here's the code:

"date": datetime.strptime(d_items['Date'], '%a,%d %b %Y %H:%M:%S %z').strftime('%Y-%m-%d %H:%M:%S')

While stripping the timezone and formatting I'm getting the below error using datetime.datetime function.

'z' is a bad directive in format '%a,%d %b %Y %H:%M:%S %z' 

Is there any other way to get the format like below:

2019-04-09 11:49:26
MSR
  • 63
  • 7

0 Answers0