时间差问题

WBOY
WBOYOriginal
2016-06-23 13:48:11895browse

$a=2014-09-30 23:21:55
$b=18:00

请问怎么算出来$a中的23:21与$b的差是多少分钟?


回复讨论(解决方案)

自己弄好了!!!

$d = new datetime(date('H:i:s', strtotime('2014-09-30 23:21:55')));$t = $d->diff(new datetime('18:00:0'));echo $t->format('%H:%I:%S  ');echo $t->h * 60 + $t->i + $t->s / 60;
05:21:55  321.91666666667

$seconds= (strtotime("2014-09-30 23:21:55")-strtotime("18:00")+86400)%86400;$minutes = floor($seconds/60);var_dump($minutes);

参考函数:strtotime

或者百度'计算时间差'

假如:
kq.kq_time的值为2014-09-30 23:21:55
kq_c.am_on的值为18:00

怎样使下面的MYSQL语句成立?
$sql_where .=" and DATE_FORMAT(kq.kq_time,'%H:%i')>kq_c.am_on";

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn