gpt4 book ai didi

php - 在 PHP 中从 INT 到时间

转载 作者:行者123 更新时间:2023-11-29 01:36:57 25 4
gpt4 key购买 nike

我在这里没有想法。

在我的数据库表中,我有各种各样的条目,它们都有一行包含 start_timeduration。在这种情况下,我可以输入值的唯一方法是:

10:00 在数据库中输入为 1000,23:00 输入为 2300。

持续时间为 1 个半小时 130 或 20 分钟 20,依此类推。

它们的输入方式与您期望的一样,没有任何符号分隔数字。问题是,我无法添加数字,需要通过添加两个值来计算 end_time

例如,如果我有一个事件从 1045 开始并持续 45,我只需要回显 1130。

最佳答案

I'll gladly change it to 0900

您可以尝试以下操作:

$timed = strtotime("+".$duration." minutes", strtotime($time));
echo date('Hi', $timed);

首先您需要转换时间并添加持续时间。之后,您可以根据需要回显它。

例如。

 $timed = strtotime("+130 minutes", strtotime("0900"));
echo date('Hi', $timed);

会输出

1110

关于php - 在 PHP 中从 INT 到时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39443779/

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