我无法通过strtotime()
添加天,小时和分钟。
代码:
$uncleanTotal = strtotime($created_time);
$uncleanTotal = strtotime("+".$timeForUnclean[0] . " days ". $timeForUnclean[1] ." hours ". $timeForUnclean[2] ." minutes");
更确切地说,我试图从之前获得时间并添加天,小时和分钟,以查看它创建的时间是否大于当前时间(现在)或小于。我使用if
语句来检查这个。
代码:
if($cautionTotal <= $now)
{
echo "working caution";
return "yellow";
}
else if( $uncleanTotal <= $now)
{
echo "working unclean";
return "red";
}
else if($cautionTotal > $now && $uncleanTotal > $now)
{
echo "working clean";
return "green";
}
连连呢?想法?
答案 0 :(得分:2)
您在要添加的语句中缺少源日期:
尝试:
$uncleanTotal = strtotime($created_time . "+".$timeForUnclean[0] . " days ". $timeForUnclean[1] ." hours ". $timeForUnclean[2] ." minutes");
或者,您可以将strtotime($created_time)
作为第二个参数传递给strtotime
,以获得与上述相同的结果:
$uncleanTotal = strtotime("+".$timeForUnclean[0] . " days ". $timeForUnclean[1] ." hours ". $timeForUnclean[2] ." minutes", strtotime($created_time));