我想要php中两个日期时间之间的差异。我想要 H:i:s 格式的差异。这是我的代码。
$start_date = 2013-08-13;
$end_date = 2013-08-23;
$start_time = 12:28:58;
$end_time = 13:16:45;
$h1 = substr("$start_time",0,-6);
$i1 = substr("$start_time",3,-3);
$s1 = substr("$start_time",6);
$h2 = substr("$end_time",0,-6);
$i2 = substr("$end_time",3,-3);
$s2 = substr("$end_time",6);
$m1 = substr("$start_date",5,-3);
$d1 = substr("$start_date",8);
$y1 = substr("$start_date",0,-6);
$m2 = substr("$end_date",5,-3);
$d2 = substr("$end_date",8);
$y2 = substr("$end_date",0,-6);
$r1=date("Y-m-d H:i:s",mktime($h1,$i1,$s1,$m1,$d1,$y1));
$r2=date("Y-m-d H:i:s",mktime($h2,$i2,$s2,$m2,$d2,$y2));