【问题标题】:Format timespan in PHP/CodeIgniter在 PHP/CodeIgniter 中格式化时间跨度
【发布时间】:2013-08-11 15:21:58
【问题描述】:

我正在做一个项目,该项目需要检查过去和现在特定时间之间的时差,并且仅在 MINUTES 中输出差异。例如,如果 Diff 为 2 小时 3 分钟。输出应为 123(即 2 小时(120 分钟)+ 3 分钟)。

我使用了 CodeIgniter timespan() 函数,但它只返回 2 小时 3 分钟。 有没有办法获得所需的输出?

【问题讨论】:

标签: php codeigniter date time timespan


【解决方案1】:

你需要这样的东西吗?

$tomorrow  = mktime(0, 0, 0, date("m")  , date("d")+1, date("Y"));
$today = mktime(0, 0, 0, date("m"), date("d"),   date("Y"));

$minutesDiff = ($tomorrow - $today)/60;
echo $minutesDiff;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多