普通网友 2011-08-16 07:27
浏览 146
已采纳

我如何直接在strtotime获得四分钟

I want to get the next rounded hour (10:00:00 instead of 10:25:01) by calling the strtotime function. The output from strtotime should translate directly to the rounded hour.

At the moment if I do

var_dump(date('Y-m-d H:i:s', strtotime('+1 hour')));

I get an unrounded value such as

string '2011-08-16 10:21:57' (length=19)

while I would like to get

string '2011-08-16 10:00:00' (length=19)

I know this can be achieved by doing:

var_dump(date('Y-m-d H:00:00', strtotime('+1 hour')));

But I'd like to achieve the same by using strtotime only. So I need a string that will evaluate to the rounded hour by strtotime.

I tried values such as

next hour, 0 minutes
+1 hour, 0 minutes
next rounded hour

but without success.

  • 写回答

1条回答 默认 最新

  • douxian7808 2011-08-16 07:58
    关注

    According to PHP's relative format docs, there's no strtotime argument for this purpose.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了
  • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
  • ¥188 需要修改一个工具,懂得汇编的人来。
  • ¥15 livecharts wpf piechart 属性
  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题