strptime for different languages

Chris Angelico rosuav at gmail.com
Tue Dec 17 14:04:15 EST 2019


On Wed, Dec 18, 2019 at 5:57 AM Barry Scott <barry at barrys-emacs.org> wrote:
>
>
>
> > On 17 Dec 2019, at 10:37, Ulrich Goebel <ml at fam-goebel.de> wrote:
> >
> > Hi,
> >
> > I need to interpret a date string to get a datetime object. That should be done with strptime from the module datetime.
> >
> > But I don't know enough about the locale settings from where the date sting comes. Actually the date_string cames from different contact forms inside websites made by different content management systems. So it could be
>
> Can side step the issue?
>
> I would change the web site to collect the date in a form that is not ambiguous.
> For example use a Javascript date picker widget.
>
> Barry

No JavaScript needed, just use <input type=date>.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date

You get back an unambiguous yyyy-mm-dd.

ChrisA


More information about the Python-list mailing list