gpt4 book ai didi

php - 如何在php中找到第二天开始的unix时间戳?

转载 作者:IT王子 更新时间:2023-10-29 00:06:28 25 4
gpt4 key购买 nike

我有一个当前时间的 unix 时间戳。我想获取第二天开始的 unix 时间戳。

$current_timestamp = time();
$allowable_start_date = strtotime('+1 day', $current_timestamp);

正如我现在所做的那样,我只是将一整天的时间添加到 unix 时间戳,而我想弄清楚这一天还剩下多少秒,并且只添加那几秒以便获取第二天第一分钟的 unix 时间戳。

最好的方法是什么?

最佳答案

当时最简单的方式就是“make”:

$tomorrowMidnight = mktime(0, 0, 0, date('n'), date('j') + 1);

引用:

I would like to figure out how many seconds are left in this current day, and only add that many seconds in order to get the unix timestamp for the very first minute of the next day.

不要那样做。尽可能避免相对计算,特别是如果“绝对”获得没有秒算术的时间戳是微不足道的。

关于php - 如何在php中找到第二天开始的unix时间戳?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2520404/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com