-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
  • 8,922
  • 18
  • 81
  • 171

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
  • 47,041
  • 7
  • 30
  • 65
1

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

Code-Apprentice
  • 76,639
  • 19
  • 130
  • 241