[SOLVED] Convert paypal date to string in python


paypal is giving me this format ’03:00:00 Mar 14, 2023 PDT’. I’ve tried different solutions but i can’t get with the right one. How can i separate each item into a string using python?


Assuming you want a datetime object

from datetime import datetime

time_string = "03:00:00 Mar 14, 2023 PDT"
d = datetime.strptime(time_string[:-4], "%H:%M:%S %b %d, %Y")


import parsedatetime as pdt # $ pip3 install parsedatetime
cal = pdt.Calendar()

time_string = "03:00:00 Mar 14, 2023 PDT"
d = cal.parseDT(time_string)[0]

Once you have your datetime, output the part(s) you want using strftime

Answered By – Preston PHX

Answer Checked By – Pedro (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *