How to convert string to datetime object in python for years 2070 and above? -
while trying convert string datetime , encountered following:
s='30-01-50' datetime.datetime.str >>datetime.date(2050, 1, 30)
however
s='30-01-70' datetime.datetime.strptime(s,"%d-%m-%y").date() >>datetime.date(1970, 1, 30)
why not 2070 ?. how 1 perform arithmetic on such datetime values?
for quick reference, see this answer.
quick answer: not use two-digit years, use four-digit years , %y
specifier.
Comments
Post a Comment