I have a date stored in a text file in this format “19 May 2021”, I want to compare this date to the today’s date to see if we have reached this date or not (> / <) comparisons. I was instructed to first convert this string date to a date object, I am failing to do so. For overdue_tasks
Tag: strptime
How can I use datetime.strptime on a string in the format ‘0000-00-00T00:00:00+00:00’?
Due to my application’s circumstances, I would prefer to use datetime.strptime instead of dateutil.parser. After looking at the docs, I thought that %Y-%m-%dT%H:%M:%S%z may be the proper format for parsing a date string like this. Yet it still gives me an error. Example Answer The easiest way to deal with timezones is to use dateutil.parser: But you have to pass
A faster strptime?
I have code which reads vast numbers of dates in ‘YYYY-MM-DD’ format. Parsing all these dates, so that it can add one, two, or three days then write back in the same format is slowing things down quite considerably. Any suggestions how to speed it up a bit (or a lot)? Answer Python 3.7+: fromisoformat() Since Python 3.7, the datetime