我想在 PHP 中获取第二天中午 12 点的时间戳

我想得到明天中午 12 点的时间戳,我可以使用下面的代码行

strtotime('tomorrow noon');

但是我遇到的问题是,当当前时间是午夜 00:00 时,我正在获取第二天的时间戳,我想要这样当时间是午夜 00:00 时,它仍然应该给出中午的时间戳新的一天不是第二天。


哔哔one
浏览 594回答 2
2回答

波斯汪

你可以做一个简单的三元:strtotime((date('H:i') == '00:00' ? '' : 'tomorrow ').'noon');或者用一个简单的 if 案例:if (date('H:i') == '00:00') {    $noon = strtotime('noon');} else {    $noon = strtotime('tomorrow noon');}

白衣染霜花

我想如果现在还没有中午,你可能想在中午显示当前日期,否则显示明天中午的时间。如果是这种情况,以下内容可能会有所帮助:$noon = strtotime('now') < strtotime('noon')&nbsp;? strtotime('noon')&nbsp;: strtotime('tomorrow noon')
打开App,查看更多内容
随时随地看视频慕课网APP