php [PHP]日期格式验证

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php [PHP]日期格式验证相关的知识,希望对你有一定的参考价值。

function checkDateFormat($date){
	//match the format of the date
	if (preg_match ("/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/", $date, $parts)){
		//check weather the date is valid of not
		if(checkdate($parts[2],$parts[3],$parts[1])){
			return true;
		}else{
		  return false;
		}
	}else{
		return false;
	}
}

以上是关于php [PHP]日期格式验证的主要内容,如果未能解决你的问题,请参考以下文章