为了防止误解:我所有的代码行都很好,并且它们工作正常。我只是在我的 date()
中有一个错误的参数,我在那里显示了秒 date('H:s')
,它应该将分钟显示为 日期('H:i')
。 (感谢 chumkiu 的提示。)
我想在 00h10 获取下一天的时间戳。
我想我可以使用 strtotime()
函数,例如喜欢
$timestamp = strtotime('tomorrow 00:10');
但是当我检查
$mydate = date('Y-m-d H:s', $timestamp);
var_dump($mydate);
输出是
string(16) "2013-10-03 00:00"
strtotime()
的文档中有很多获取不同时间的例子
echo strtotime("now"), "\n";
echo strtotime("10 September 2000"), "\n";
echo strtotime("+1 day"), "\n";
echo strtotime("+1 week"), "\n";
echo strtotime("+1 week 2 days 4 hours 2 seconds"), "\n";
echo strtotime("next Thursday"), "\n";
echo strtotime("last Monday"), "\n";
但他们都没有接近我的问题。
有趣的是:我可以做到这一点
$time_h = strtotime('tomorrow +10 hours');
$time_m = strtotime('tomorrow +10 minutes');
虽然 $time_h
返回想要的结果 (10:00
),但 $time_m
没有。
有什么想法吗?
最佳答案
简单
echo date("Y-m-d 00:10",strtotime('tomorrow'))
但是在您的代码中,错误是使用 H:s
而不是 H:i
来自 doc :
i: Minutes with leading zeros | 00 to 59
s: Seconds, with leading zeros | 00 through 59
关于php - 我怎样才能得到明天 00h10 的时间戳?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19136194/