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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -