我想在现在和将来之间得到分钟,请帮助我!
$time = now - future time
echo minutes
答案 0 :(得分:0)
我认为你正在寻找这个:
date('Y-m-d H:i:s')
查看此链接以获取更多信息http://pl.php.net/manual/en/function.date.php
如果您正在寻找Datetime类,请查看以下链接: http://php.net/manual/en/class.datetime.php
如果你想要时间之间的差异,你需要这个:
$to_time = strtotime("2008-12-13 10:42:00");
$from_time = strtotime("2008-12-13 10:21:00");
echo round(abs($to_time - $from_time) / 60,2). " minute";
答案 1 :(得分:0)
您可以使用DateTime类来获得所需的结果
$now = new DateTime();
$date = new DateTime("2014-10-20 12:13:29");
//calculate the difference between two dates
$diff = $now->diff($date);
//caculate number of minutes between two dates
$minutes = $diff->days * 24 * 60;
$minutes += $diff->h * 60;
$minutes += $diff->i;
// display difference in minutes
echo $minutes.' minutes';