function getYMDHMSPastFromTwoDate($startTimeStamp,$endTimeStamp)
{
$years = ”;
$Month = ”;
$Days = ”;
$Hrs = ”;
$Mins = ”;
$totalSecs = ”;
$timePastArr = array();
$date1 = $startTimeStamp;
$date2 = $endTimeStamp;
if($date1 > $date2)
{
$dateDiff = intval($date1 – $date2);
}
else
{
$dateDiff = intval($date2 – $date1);
}

$totalYears = $dateDiff/(365*24*60*60);
$years = floor($totalYears);
$timeRemaining = ($dateDiff – ($years*365*24*60*60));
$totalMonth = $timeRemaining/(30*24*60*60);
$Month = floor($totalMonth);
$timeRemaining = $timeRemaining – $Month*30*24*60*60;
$totalDays = $timeRemaining/(24*60*60);
$Days = floor($totalDays);
$timeRemaining = $timeRemaining-$Days*60*60*24;
$totalHrs = $timeRemaining/(60*60);
$Hrs = floor($totalHrs);
$timeRemaining = $timeRemaining-$Hrs*60*60;
$totalMins = $timeRemaining/60;
$Mins = floor($totalMins);
$timeRemaining = $timeRemaining-$Mins*60;
$totalSecs = floor($timeRemaining);

return $timePastArr = array(‘year’=>$years,’month’=>$Month,’days’=>$Days,’hours’=>$Hrs,’minutes’=>$Mins,’seconds’=>$totalSecs);

}

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.