Issue
I have date in the form of YYYY-MM-DD how can i format that date into Aug 26, 2022.
def return_date():
date_returned = YYYY-MM-DD
return date_returned in form of Aug 26, 2022
Solution
Is this what you are trying to accomplish?
import datetime
def return_date(ymd_format):
year, month, day = ymd_format.split("-")
return datetime.datetime(int(year), int(month), int(day)).strftime("%b %d, %Y")
print(return_date("2022-08-26")) # prints "Aug 26, 2022"
Answered By - JRose
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.