我被困在如何使用 mktime 上。我如何知道解除禁令的日期?
$time = strtotime($banrow['time']); //when user got banned
//1 week
$banduration = 60*60*24*7;
$newtime = $time+$banduration;
echo date('Y-m-d',mktime());
我被困在如何使用 mktime 上。我如何知道解除禁令的日期?
$time = strtotime($banrow['time']); //when user got banned
//1 week
$banduration = 60*60*24*7;
$newtime = $time+$banduration;
echo date('Y-m-d',mktime());
这就是date("Y-m-d",$newtime);
你所需要的。
使用下面的代码作为示例,看看它是如何工作的
$time = mktime(11, 14, 54, 8, 12, 2014);
//mktime(hour,minute,second,month,day,year) as the right order
echo "Create time is ".date('Y-m-d h:i:s',$time);// year first
echo "<br>";
echo "Create time is ".date('d-m-Y h:i:s',$time);//day first
echo "<br>";
echo "Year is ".date('Y',$time);//Just print Year
echo "<br>";
echo "Month is ".date('m',$time);//just print month
//use date(format,optional)
//the format can be what you want it to be display
输出是
Create time is 2014-08-12 11:14:54
Create time is 12-08-2014 11:14:54
Year is 2014
Month is 08
?>