Skip to content
Advertisement

Formatting todays date in python as date type

I’m trying to get todays date in the format %d/%m/%y without converting to a string. I still want to have the date as the data type.

Following code returns an str

JavaScript

Advertisement

Answer

This is the right way to achieve your goal:

JavaScript

Output:

JavaScript

To change the date class default format:

mydatetime.py

JavaScript

Read More: How to globally change the default date format in Python

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement