get php DateInterval in total 'minutes'

前端 未结 5 524
鱼传尺愫
鱼传尺愫 2020-12-15 03:21

I am trying to get the PHP \"DateInterval\" value in \"total minutes\" value. How to get it? Seems like simple format(\"%i minutes\") not working?

Here is the sampl

5条回答
  •  囚心锁ツ
    2020-12-15 04:02

    That works perfectly.

    function calculateMinutes(DateInterval $int){
        $days = $int->format('%a');
        return ($days * 24 * 60) + ($int->h * 60) + $int->i;
    }
    

提交回复
热议问题