多个日期的小时数

时间:2014-10-25 20:53:40

标签: php symfony

我有一个小时数。

foreach ($horaires as $horaire) {

    $addition += strtotime($horaire->getPointNbh()->format('H:m:s'));

}

它不起作用。有人可以帮我讲解如何使用Symfony 2在DateTime Type上进行操作。

谢谢

1 个答案:

答案 0 :(得分:0)

没有Symfony或Datetime对象的解决方案,这是我的解决方案:

    $heure = 0;
    foreach ($horaires as $horaire) {
        $heure += $horaire->getPointNbh()->format('H') *3600 + $horaire->getPointNbh()->format('i') *60 + $horaire->getPointNbh()->format('s');  ;
        //$heure = $heure * 3600;

    }
    $hour = floor($heure /3600);
    $min = floor($heure%3600/60);
    $sec = $heure - (($hour*3600) + ($min*60));
    $result = $hour.":".$min.":".$sec;

    return $result;
相关问题