Correct Regular expressions to match a date

后端 未结 11 645
不知归路
不知归路 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:35

     ^\d{4}-\d{2}-\d{2}$
    

    but no regular expression can prevent someone to enter "9867-39-56"

提交回复
热议问题