RosettaCodeData/Task/Date-format/Python/date-format.py

13 lines
341 B
Python
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
import datetime
2026-02-01 16:33:20 -08:00
2023-07-01 11:58:00 -04:00
today = datetime.date.today()
2026-02-01 16:33:20 -08:00
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}")