我想使用php将一个日期减去另一个日期,并以天 - 小时 - 分 - 秒格式显示结果.我是怎么用php做的.我尝试使用时间戳,但它没有给出正确的值.请给出建议
例如:从2012-04-27 19:30:56到2012-04-27 19:37:56
我用这个代码
if(strtotime($history['datetimestamp']) > strtotime($lasttime)) {
$totalelapsed1 = (strtotime($history['datetimestamp'])-strtotime($lasttime));
if($totalelapsed1 > 60 ) {
$sec = $totalelapsed1%60;
$min = round($totalelapsed1/60 , 0);
$minute = $min + $minute;
$second = $sec + $second;
// echo $min. " min " .$sec." sec";
} else {
//echo "0 min " . $totalelapsed1." sec";
$minute = 0 + $minute;
$second = $totalelapsed1 + $second;
}
} else {
$minute = 0 + $minute;
$second = …Run Code Online (Sandbox Code Playgroud) php ×1