If I have a string that contain a date, like '29/01/21'
, how can I convert its format to a 4 year digit instead of 2 digits?
'29/01/21'
to
'29/01/2021'
If I have a string that contain a date, like '29/01/21'
, how can I convert its format to a 4 year digit instead of 2 digits?
'29/01/21'
to
'29/01/2021'
This is one solution:
mystring = '29/01/21'
mystring = mystring[:6]+'20'+mystring[-2:]
print(mystring)
Output:
'29/01/2021'