本文介绍了Round datetime到最后一小时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在MySQL数据库中有datetime值,必须是
示例,所有这些值:
应该向下舍入:
和
应该是:
获取日期值的PHP代码:
$ d = strtotime($ row [date]);
那么,如何舍去datetime值呢?
解决方案
尝试这个,
$ date =2013-04-20 16:25:34;
echo date(Y-m-d H:00:00,strtotime($ date));
I tried to look for this but I could not find good example of this what im trying to do.
I got datetime values in MySQL database that has to be rounded down when that value is on use.
Example, all these values:
Should be rounded down to:
And
should be:
PHP code that gets date value:
$d = strtotime($row["date"]);
So, how its possible to round down datetime value?
解决方案
Try this,
$date = "2013-04-20 16:25:34";
echo date("Y-m-d H:00:00",strtotime($date));
这篇关于Round datetime到最后一小时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!