【发布时间】:2018-01-07 15:39:33
【问题描述】:
我希望有 2 个以小时为单位的当前时间变量:分钟,还有一个具有 +15 分钟的变量。但首先我还必须加上 +6 小时。
例如,现在是2018-01-07 16:35:10。所以首先我增加了+6小时。所以它将是2018-01-07 22:35:10。接下来,我只想提取小时:分钟。
我只想将“22:35”变为变量。
下一个变量,我想要 22:35 +15 分钟,所以是 22:50。
所以我有$dateNow = 22:35 和$dateThen = 22:50
到目前为止,我已经尝试过获取当前时间和 +6 小时,但它不起作用。错误:Call to a member function format() on integer
$now = strtotime(date("Y-m-d H:i:s")." +6 hours");
$then = $now->format('H:i');
echo $then;
【问题讨论】:
标签: php date datetime timestamp