我想得到明天中午 12 点的时间戳,我可以使用下面的代码行strtotime('tomorrow noon');但是我遇到的问题是,当当前时间是午夜 00:00 时,我正在获取第二天的时间戳,我想要这样当时间是午夜 00:00 时,它仍然应该给出中午的时间戳新的一天不是第二天。
2 回答
波斯汪
TA贡献1811条经验 获得超4个赞
你可以做一个简单的三元:
strtotime((date('H:i') == '00:00' ? '' : 'tomorrow ').'noon');
或者用一个简单的 if 案例:
if (date('H:i') == '00:00') {
$noon = strtotime('noon');
} else {
$noon = strtotime('tomorrow noon');
}
白衣染霜花
TA贡献1796条经验 获得超10个赞
我想如果现在还没有中午,你可能想在中午显示当前日期,否则显示明天中午的时间。如果是这种情况,以下内容可能会有所帮助:
$noon = strtotime('now') < strtotime('noon')
? strtotime('noon')
: strtotime('tomorrow noon')
- 2 回答
- 0 关注
- 593 浏览
添加回答
举报
0/150
提交
取消
