$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;
