Check Pending Month, Date, Time Using SafTimeDiff

<?
//Pass the Date Time (Format yyyy-mm-dd hh:mm:ss)
function SafTimeDiff($timestamp){
if ((
$timestamp=="0000-00-00 00:00:00") or (!$timestamp)) {
return
"";
}else{
list(
$year,$month,$day,$hour,$minute,$second) = explode("-",str_replace(array(" ",":"),"-",$timestamp));
$until = mktime($hour,$minute,$second,$month,$day,$year);
$now = time();
$difference = $now - $until;

$months = floor($difference/2592000);
$difference = $difference - ($months*2592000);

$days = floor($difference/86400);
$difference = $difference - ($days*86400);

$hours = floor($difference/3600);
$difference = $difference - ($hours*3600);

$minutes = floor($difference/60);
$difference = $difference - ($minutes*60);

$seconds = $difference;

if (
$months!=0) {
$output = $months. "M ";
}
if (
$days!=0) {
$output = $output . $days. "D ";
}
if (
$hours!=0) {
$output = $output . $hours. "H ";
}
if (
$minutes!=0) {
$output = $output . $minutes. "Min ";
}
if (
$seconds!=0) {
$output = $output . $seconds. "Sec ";
}
return
$output;
}
}
?>