Is there a Python module to parse a date like the 'date' command in Linux?

Chris Green cl at isbd.net
Sat May 20 15:53:57 EDT 2023


I'm converting a bash script to python as it has become rather clumsy
in bash.

However I have hit a problem with converting dates, the bash script
has:-

    dat=$(date --date "$1" +"%Y/%m/%d")

and this will accept almost anything reasonably sensible that can be
interpreted as a date, in particular it accepts things like "tomorrow",
"yesterday" and "next thursday".

Is there anything similar in Python or would I be better off simply
using os.system() to run date from the python program?

-- 
Chris Green
·


More information about the Python-list mailing list