LoginSignup
12
14

More than 5 years have passed since last update.

二つの時刻の差を求める

Posted at

二つの時刻の差を求める

びっくりしたことにphpには二つの時刻の差を求める関数がないみたい。

なのでこうする。

diffTime.php

function diffTime($start,$end) {

  $startSec = strtotime($start);
  $endSec   = strtotime($end);

  $diff = $endSec - $startSec;

  return gmdate('h:i:s',$diff);

}
12
14
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
14