javascript regex iso datetime

前端 未结 9 1977
没有蜡笔的小新
没有蜡笔的小新 2020-12-02 16:31

does anyone have a good regex pattern for matching iso datetimes?

ie: 2010-06-15T00:00:00

9条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-02 17:07

    For matching just ISO date, like 2017-09-22, you can use this regexp:

    ^\d{4}-([0]\d|1[0-2])-([0-2]\d|3[01])$
    

    It will match any numeric year, any month specified by two digits in range 00-12 and any date specified by two digits in range 00-31

提交回复
热议问题