为了防止误解:我所有的代码行都很好,而且它们工作正常。我只是在我的date()中出现了一个错误的参数,在这里我显示了秒date('H:s'),在那里它应该将分钟显示为date('H:i')。(感谢竹鸡给出的提示。)
我想取下下一天的时间戳,时间是零时十分。
我想我可以使用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不返回。
有什么想法吗?
发布于 2013-10-02 11:50:36
简单地说
echo date("Y-m-d 00:10",strtotime('tomorrow'))但是,在您的代码中,错误是使用H:s而不是H:i
来自文档
i:带前导零的分钟00到59 s:秒,前导0到59
发布于 2013-10-02 11:52:56
只需加10分钟:
$timestamp = strtotime('tomorrow +10min');https://stackoverflow.com/questions/19136194
复制相似问题