php - 我怎样才能得到明天 00h10 的时间戳?

标签 php date time

为了防止误解:我所有的代码行都很好,并且它们工作正常。我只是在我的 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/

相关文章:

java - 获取启用时区的 DateTime 实例的字母数字月份值

javascript - 使用 angularjs 过滤日期时出现引用错误

php - 需要更改文件路径及其在数据库中的 ID

如果 CURDATE() 匹配,则 PHP/MYSQL 在重复键更新时插入,否则创建新条目

javascript - 为什么这段代码运行错误

Java 使用 Joda 时间将军事时间转换为民用时间

php - FOSOAuthServerBundle 和 FOSUserBundle - 如何让它工作?

php - 布局中缺少带有链接的 [Route : homepage. edit] 所需参数

PHP - 计算日期和当前日期之间的月数

sql - Bigquery iso8601 字符串转时间戳