【发布时间】:2011-02-25 02:11:14
【问题描述】:
我正在尝试从当前时间制定时间表 到 12 小时后。我正在使用 date() 函数 检索当前时间,但如何增加 小时和调整上午/下午?我可以在 date() 上加 1 功能?
感谢您的帮助。
【问题讨论】:
我正在尝试从当前时间制定时间表 到 12 小时后。我正在使用 date() 函数 检索当前时间,但如何增加 小时和调整上午/下午?我可以在 date() 上加 1 功能?
感谢您的帮助。
【问题讨论】:
$now = time();
$then = $now + 12 * 60 * 60;
echo date(format, $then);
【讨论】:
你可以使用strtotime:
date('d-m-Y H:i:s', strtotime('+1 hour')); // one hour since now
或
date('d-m-Y H:i:s', strtotime('2011-02-25 14:00:42'));
【讨论】:
$mydate = date("dateformat", time() + 43200);
time() 获取当前时间戳,然后添加 43200 即 12 小时 * 60 分钟 * 60 秒
【讨论】: