2025-08-03 11:27:36 +0000 UTC
Reformat Date
Categories:
Links
Code
class Solution:
def reformatDate(self, date: str) -> str:
day_str, mnth_str, year_str = date.split()
if len(day_str) == 3:
day = int(day_str[0:1])
else:
day = int(day_str[0:2])
mnth = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"].index(mnth_str) + 1
year = int(year_str)
return f"{year}-{mnth:02}-{day:02}"