PHP:将时间添加到当前时间? [英] PHP: Adding time to current time?

查看:33
本文介绍了PHP:将时间添加到当前时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将当前时间增加 15 分钟.我正在使用以下代码:

I am trying to add 15minutes to the current time. I am using the following code:

$curtime = date('H:i');                     
$newtime = $curtime + strtotime('+15 minutes');

但这仍然只打印当前时间,而不是当前时间 + 15.

But this still only prints the current time and not the current time + 15.

我希望它像这样增加 15 分钟

I want it to add 15mins like so

例如如果时间是12:30,添加后的时间就是12:45

e.g. If the time is 12:30 the time after addition will be 12:45

谢谢.

推荐答案

关闭,你想要:

$new_time = date('H:i', strtotime('+15 minutes'));

这篇关于PHP:将时间添加到当前时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆