vinhngba2704's picture
First commit to this repo
51db8d1
raw
history blame contribute delete
512 Bytes
from datetime import datetime
from dateutil import parser
# Function to format the date
def format_date(date_str):
try:
# Use dateutil.parser to automatically parse date string
raw_order_date = parser.parse(date_str)
# Format the datetime object into dd/mm/yyyy
return raw_order_date.strftime("%d/%m/%Y")
except Exception as e:
print(f"Failed to parse date '{date_str}': {e}")
# If parsing fail, return the original date string
return date_str