PHP用正则表达式 判断是否为Y-m-d 时间格式解决方法

WBOY
Release: 2016-06-13 12:24:07
Original
1709 people have browsed it

PHP用正则表达式 判断是否为Y-m-d 时间格式
目前的是
if(ereg("^(19|20)\d{2}-(0?\d|1[012])-(0?\d|[12]\d|3[01])$",$sDate))

这样只能是YYYY-MM-DD的格式

如果我要用YYYY-M-D的格式怎么写呢?
------解决思路----------------------
同样能支持 YYYY-M-D 格式!
虽然你有意张冠李戴([0-9] 写成 \d)

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template