当前位置 : 主页 > 网络编程 > PHP >

PHP计算日期差异

来源:互联网 收集:自由互联 发布时间:2021-07-03
date_default_timezone_set("Asia/Calcutta");function dt_differ($start, $end){ $start = date("G:i:s:m:d:Y", strtotime($start)); $date1=explode(":", $start); $end = date("G:i:s:m:d:Y", strtotime($end)); $date2=explode(":", $end); $starttime =
 
date_default_timezone_set("Asia/Calcutta");

function dt_differ($start, $end){
  $start = date("G:i:s:m:d:Y", strtotime($start));
  $date1=explode(":", $start);

  $end  = date("G:i:s:m:d:Y", strtotime($end));
  $date2=explode(":", $end);
     
  $starttime = mktime(date($date1[0]),date($date1[1]),date($date1[2]),
  date($date1[3]),date($date1[4]),date($date1[5]));
  $endtime   = mktime(date($date2[0]),date($date2[1]),date($date2[2]),
  date($date2[3]),date($date2[4]),date($date2[5]));

  $seconds_dif = $starttime-$endtime;

  return $seconds_dif;
}
网友评论