計算時間差值

function unix_time ($gmt_time) {
      $gmt_time_format_d = explode("-",$gmt_time);
      $time_Y = $gmt_time_format_d["0"];
      $time_m = $gmt_time_format_d["1"];
      $time_d_format = $gmt_time_format_d["2"];
      $time_d_format = explode(" ",$gmt_time_format_d["2"]);
      $time_d = $time_d_format["0"];
      $time_gmt_format_s = $time_d_format["1"];
      $time_gmt_format_s = explode(":",$time_gmt_format_s);
      $time_H = $time_gmt_format_s["0"];
      $time_i = $time_gmt_format_s["1"];
      $time_unix = mktime($time_H,$time_i,$time_s,$time_m,$time_d,$time_Y);
      return $time_unix;
  }
 
  function time_reduce($time_start,$time_end,$type) {
      $time_start = unix_time($time_start);
      $time_end = unix_time($time_end);
      $time_reduce = $time_end-$time_start;
    if ($type=="s") {
        $time_reduce = number_format($time_reduce, 2);
    }
      elseif ($type=="m") {
          $time_reduce = number_format(($time_reduce/60), 2);
      }
      elseif ($type=="h") {
          $time_reduce = number_format(($time_reduce/3600), 2);
      }
      return $time_reduce;
  }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章