Correct Regular expressions to match a date

后端 未结 11 642
不知归路
不知归路 2021-01-27 09:50

What is the correct regular expression to use to validate a date like. 2009-10-22 or 2009-01-01 etc. Platform PHP

11条回答
  •  别那么骄傲
    2021-01-27 10:34

    found this on the web tested it with a few dates and looks stable, for dates between 1900 and 2000:

    (19|20)\d\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])
    

提交回复
热议问题