我有两个日期:
Start Date: 2007-03-24
End Date: 2009-06-26
Run Code Online (Sandbox Code Playgroud)
现在我需要通过以下形式找到这两者之间的差异:
2 years, 3 months and 2 days
Run Code Online (Sandbox Code Playgroud)
我怎么能用PHP做到这一点?
我正在运行一个脚本,它决定了我的执行时间.在计算时间时我得到负数.我希望它在执行时给我一个肯定的.
<?php
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;
echo "executed";
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = ($endtime - $starttime);
$minutes = (int)($totaltime/60)-$hours*60;
echo "This page was created in ".$minutes." minute/s";
?>
Run Code Online (Sandbox Code Playgroud)