Home  >  Article  >  Backend Development  >  PHP calculate date difference

PHP calculate date difference

WBOY
WBOYOriginal
2016-07-25 08:43:28777browse
  1. date_default_timezone_set("Asia/Calcutta");
  2. function dt_differ($start, $end){
  3. $start = date("G:i:s:m:d:Y", strtotime($start));
  4. $date1=explode(":", $start);
  5. $end = date("G:i:s:m:d:Y", strtotime($end));
  6. $date2=explode(":", $end);
  7. $starttime = mktime(date($date1[0]),date($date1[1]),date($date1[2]),
  8. date($date1[3]),date($date1[4]),date($date1[5]));
  9. $endtime = mktime(date($date2[0]),date($date2[1]),date($date2[2]),
  10. date($date2[3]),date($date2[4]),date($date2[5]));
  11. $seconds_dif = $starttime-$endtime;
  12. return $seconds_dif;
  13. }
复制代码

PHP


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn