[英]How to Compare Dates in php?
i need code to compare date in php 我需要代码来比较PHP中的日期
can anyone help on this. 谁能帮上忙。 Thanks Ramakrishnan.p 谢谢Ramakrishnan.p
This is a late answer. 这是一个较晚的答案。 since there is no exact answer to the question here, I'm providing this solution here. 由于此处没有确切的问题答案,因此我在此处提供此解决方案。
You can do it in this way 你可以这样
$date1 = strtotime("2007-02-20"); // your input
$date2 = strtotime("today"); //today
if($date1 < $date2) {
echo " input date is in the past";
}
strtotime converts the string in to the unix timestamp integer. strtotime将字符串转换为unix时间戳整数。
Take a look at the maketime() function. 看一下maketime()函数。 Then compare the resulting UNIX timestamps. 然后比较所得的UNIX时间戳。
查看Zend Framework的日期: http ://framework.zend.com/manual/en/zend.date.overview.html您只需要框架中的Date.php文件和Date / Locale文件夹即可使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.