Last active
December 30, 2020 12:26
-
-
Save tamalchowdhury/96dc2f9c126c32f5ff03b972ee64da08 to your computer and use it in GitHub Desktop.
Convert date to dd-mm-yyyy with Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This function takes a date and converts into | |
| # desired format dd-mm-yyyy | |
| # Use inside a loop to make the conversion | |
| def convert_date(dateobject): | |
| return dateobject.strftime('%d-%m-%Y') | |
| # Example | |
| from datetime import datetime | |
| date_stamp = datetime.today() | |
| print(convert_date(date_stamp)) | |
| # >>> 30-12-2020 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment