Using the following to calculate today's date. import datetime
today = datetime.date.today()
print(today)
It returns the date in format of 2020-04-08 However I need it in the format of 4/8/20
How might I accomplish this?
Using the following to calculate today's date. import datetime
today = datetime.date.today()
print(today)
It returns the date in format of 2020-04-08 However I need it in the format of 4/8/20
How might I accomplish this?
Use -
to remove the leading zeros from day and month:
from datetime import date
d = date.today().strftime("%-m/%-d/%y")
print(d)
If you use Windows, change the format string to "%#m/%#d/%y"
try this
from datetime import date
today = date.today().strftime("%m/%d/%y")
print(today)