Categories
Python Answers

How to turn a Python datetime into a string, with readable format date?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

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