$time='2013-8-3';
$result=preg_match("/^[0-9]{4}(\-|\/)[0-9]{1,2}(\\1)[0-9]{1,2}(|\s+[0-9]{1,2}(|:[0-9]{1,2}(|:[0-9]{1,2})))$/",$time);
if($result)
echo('正确的日期格式');
else
echo('错误的日期格式');
SyntaxHighlighter.highlight();
$time='2013-8-3';
$result=preg_match("/^[0-9]{4}(\-|\/)[0-9]{1,2}(\\1)[0-9]{1,2}(|\s+[0-9]{1,2}(|:[0-9]{1,2}(|:[0-9]{1,2})))$/",$time);
if($result)
echo('正确的日期格式');
else
echo('错误的日期格式');
SyntaxHighlighter.highlight();