remove 0 from date in python 1

remove 0 from date in python

a_date =, 7, 14)
string_date = a_date.strftime("%-m/%-d/%Y")

Here is what the above code is Doing:
1. We create a date object using the datetime module.
2. We use the strftime method to format the date object.
3. We use the %-m and %-d format codes to remove the leading zero from the month and day.
4. We use the %Y format code to display the year with four digits.

Similar Posts