<?
//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;
}
}
?>
Blogger templates
Blogger news
Blogroll
Archives
-
▼
2011
(212)
-
▼
September
(20)
- Check number of days between 2 dates
- Interview Questions PHP :1) Explain http life cycl...
- The History of MySQL
- PHP and Cookies
- create thumbnail by script
- Integers data type in php
- Conclusion
- Check Pending Month, Date, Time Using SafTimeDiff
- PHP Opcode Caches
- PHP script for Spell Check
- Como poner comentarios en el codigo Php
- ListCount
- What is Php
- K2? --- The powerful content component for Joomla!
- function with parameters in php
- Php developer,website development,website design
- No title
- No title
- 83 PHP Scripts
- For checking all checkboxes in a form using jquery
-
▼
September
(20)