How to check if a string is a legal “dd/mm/yyyy” date?

前端 未结 7 1990
遥遥无期
遥遥无期 2020-12-01 15:05

Given a string str, how could I check if it is in the dd/mm/yyyy format and contains a legal date ?

Some examples:

bla bla          


        
7条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-01 15:33

    Personally, I think the best solution would be to modify the UI to use dropdowns for the month and possibly day selections.

    Trying to figure out if 1/2/2001 is January 2nd or February 1st based solely on that input string is impossible.

提交回复
热议问题