With the following code:
current_date = datetime.strptime(row[0], "%Y-%m-%d")
dates.append(current_date)
I want to return the dates in the string format (i.e. "Jan 2014"
) but it's returning the dates in the original format as "2014-01-01"
.
With the following code:
current_date = datetime.strptime(row[0], "%Y-%m-%d")
dates.append(current_date)
I want to return the dates in the string format (i.e. "Jan 2014"
) but it's returning the dates in the original format as "2014-01-01"
.
Copyright © 2021 Jogjafile Inc.
The default string representation of a
date
object is a string representing the date in ISO 8601 format,'YYYY-MM-DD'
. To represent dates in other format, usedate.strftime()
, e.g.:For a complete list of formatting directives, see strftime() and strptime() Behavior.