Format DateTime Python

This Python DateTime tutorial will teach you how to set the format of DateTime Python. You can set the format using the following code:

# Import the datetime module
import datetime

# Get the current date and time
date_time = datetime.datetime.now()

# Format the date and time
date_time = date_time.strftime("%d/%m/%Y %H:%M:%S")

# Display the date and time
print("Current date and time:", str(date_time))

Output:

Current date and time: 09/12/2022 06:25:15

Free learning resources: AiHintsCodeAllow

Leave a Comment

Your email address will not be published.