-1

I have strings like this Wed Mar 18 19:24:07 +0000 2020

I guess it should be ,,,

%a %b %d %X %z %Y

However , how can I put this in python datetime class??

whitebear
  • 11,200
  • 24
  • 114
  • 237

2 Answers2

2

You may use datetime.strptime() and the codes from here :

value = "Wed Mar 18 19:24:07 +0000 2020"
d = datetime.strptime(value, "%a %b %d %H:%M:%S %z %Y")
print(d)  # 2020-03-18 19:24:07+00:00
azro
  • 53,056
  • 7
  • 34
  • 70
1

Use strptime() to parse the string as a datetime object.

Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268