How to print a date in a regular format with Python?

Estimated read time 1 min read

To print a date in a regular format using Python, you can utilize the datetime module. Here’s an example of how you can achieve this:

import datetime

# Get the current date and time
current_date =

# Format the date in a regular format
formatted_date = current_date.strftime("%Y-%m-%d")

# Print the formatted date

In the code above, the function retrieves the current date and time. Then, the strftime() method is used to format the date according to a specified format string. In this case, %Y-%m-%d represents the year, month, and day in a four-digit year format, separated by hyphens. Finally, the formatted date is printed using the print() function.

You May Also Like

More From Author

+ There are no comments

Add yours

Leave a Reply