在项目中经常会在某个时候停止某个功能,这儿写一下作为备份:
int mktime ([ int $hour = date("H") [, int $minute = date("i") [, int $second = date("s") [, int $month = date("n") [, int $day = date("j") [, int $year = date("Y") [, int $is_dst = -1 ]]]]]]] )
Returns the Unix timestamp corresponding to the arguments given. This timestamp is a long integer containing the number of seconds between the Unix Epoch (January 1 1970 00:00:00 GMT) and the time specified.
Arguments may be left out in order from right to left; any arguments thus omitted will be set to the current value according to the local date and time.
$nowDate=mktime(date(‘H’),date(‘i’),date(‘s’),date(‘m’),date(‘d’),date(‘Y’));
$forbidden_end = mktime(23,59,59,3,31,2010);//结束时间
if($nowDate >= $forbidden_end)
{
$content = json_encode ( array ("code" => -1, "message" => "温馨提示:**活动已经结束,谢谢你的参与!"));
return $content;
}
$forbidden_end = mktime(23,59,59,3,31,2010);//结束时间
if($nowDate >= $forbidden_end)
{
$content = json_encode ( array ("code" => -1, "message" => "温馨提示:**活动已经结束,谢谢你的参与!"));
return $content;
}
<?php //strtotime $现在=strtotime(date('Y-m-d H:i:s')); //现在时间 $记录时间=strtotime('2008-03-28 23:44:22');//记录时间 $差距=$现在-$记录时间;//现在时间减掉记录时间 if($差距>3600)//1时间 { echo "一小时过了------差距: ".$差距."秒==".(int)($差距/60)."分"; } else { echo '一小时还没过------差距: '.$差距."秒==".(int)($差距/60)."分"; } ?>