我有当前的日期格式$date = 'yyyy-mm-dd hh:mm',并注意到已经设置了$date,并且没有使用Date类。我知道我必须使用strtotime,这是我对$date $datestr = strtotime($date)所做的。我想把5分钟减到规定的时间。
我试过这个简单的事情,$A = strtotime($date) - strtotime('-5 min');,但它对我没有帮助。
发布于 2014-02-17 08:29:28
从你的时间中减去seconds of 5 minutes,也就是(5*60)=300,很简单
像这样
$time = strtotime($date);
$time_new = $time-(5*60); // will time of the -5 min from the current $time示例
$date = date('d-M-Y g:i:s A'); // current date
echo $date."<br/>"; // output : 17-Feb-2014 8:35:58 AM
$time = strtotime($date); // convert current date to timestamp
$time_new = $time - (5*60); // subtract 5 minutes from current time.
$date_new = date('d-M-Y g:i:s A', $time_new); // convert time to the date again
echo $date_new; // output : 17-Feb-2014 8:30:58 AM https://stackoverflow.com/questions/21824070
复制相似问题