1lastconnection = datetime.strptime("21/12/2008", "%d/%m/%Y").strftime('%Y-%m-%d')
1import re
2def change_date_format(dt):
3 return re.sub(r'(\d{4})-(\d{1,2})-(\d{1,2})', '\\3-\\2-\\1', dt)
4dt1 = "2026-01-02"
5print("Original date in YYY-MM-DD Format: ",dt1)
6print("New date in DD-MM-YYYY Format: ",change_date_format(dt1))
7
8
1lastconnection = datetime.datetime.strptime("21/12/2008", "%d/%m/%Y").strftime('%Y-%m-%d')
2#corrected version