Sometimes, we want to turn a Python datetime into a string, with readable format date.
In this article, we’ll look at how to turn a Python datetime into a string, with readable format date.
How to turn a Python datetime into a string, with readable format date?
To turn a Python datetime into a string, with readable format date, we can use the strftime
method.
For instance, we write
d = my_datetime.strftime("%B %d, %Y")
to call my_datetime.strftime
with the date format string to return a date formatted with the month, date and year from the my_datetime
datetime object.
Conclusion
To turn a Python datetime into a string, with readable format date, we can use the strftime
method.