简体   繁体   中英

Date.strptime throwing invalid date for “%Y%W” format

My date = 1st January, 2015. I did date_formatted = date.strftime('%Y%W') which returned "201500"

Then when am trying to do Date.strptime(date_formatted, '%Y%W') it's throwing an invalid date error even though the original string was returned from strptime's counterpart srftime.

Found the solution. Time.strptime(date_formatted, '%Y%W') is what will work here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM