top of page

Write a Program to Print Today's Date in Python

Code:


Without strftime() method

from datetime import date

today = date.today()
print("Today's date:", today)

We use the strftime() method to create a string representing date in different formats.

from datetime import date

today = date.today()
print("Program to Print Today's Date") 
# dd/mm/YY
d1 = today.strftime("%d/%m/%Y")
print("Date type 1 =", d1)

# Textual month, day and year	
d2 = today.strftime("%B %d, %Y")
print("Date type 2 =", d2)

Output:




The Tech Platform

0 comments
bottom of page