[英]PHP is date past due?
Ok, I have a "due date" formatted like this: 08/31/2012 (M/D/Y). 好的,我有一个“截止日期”格式如下:08/31/2012(M / D / Y)。 What I would like to do using PHP compare the returned string as shown against the current date.
我想用PHP比较当前日期显示的返回字符串。 If the string above is older than the current date...execute some code.
如果上面的字符串早于当前日期...执行一些代码。
I know this seems simple but it is throwing me for a loop. 我知道这看起来很简单但却让我陷入了困境。
thanks for any help! 谢谢你的帮助!
Do you mean that if the string-date is older do this and if not do that? 你的意思是,如果字符串日期更早,那么这样做,如果不这样做?
<?php
$string = '08/31/2012';
if(strtotime($string) < time()){
echo 'Old';
}else{
echo 'Not happened yet';
}
更改为格式YYYY-MM-DD
并简单地比较为字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.