RosettaCodeData/Task/Date-format/Python/date-format.py
2026-02-01 16:33:20 -08:00

12 lines
341 B
Python

import datetime
today = datetime.date.today()
print(today.strftime("%Y-%m-%d"))
# Or using the `isoformat` method of `date`.
print(today.isoformat())
print(today.strftime("%A, %B %d, %Y"))
# Or using a "format specifier" with `str.format` or an f-string.
print("{today:%A, %B %d, %Y}".format(today=today))
print(f"{today:%A, %B %d, %Y}")