Tuesday, July 2, 2013

Display Fancy Date Format for Wordpress Post

Hello Friends,

 Today we learn how how to convert seconds into a fancy format.that is done by a Simple Php Function to convert Seconds into human readable format like month,day,hour,minutes.This function used in anywhere like wordpress,joomla,magento or simple php script.
 first you have to provide a second in function.

Example code :

$seconds=137267; 
function seconds2human($ss) 

  $s = $ss%60;
  $m = floor(($ss%3600)/60);
  $h = floor(($ss%86400)/3600);
  $d = floor(($ss%2592000)/86400);
  //$M = floor($ss/2592000);
  return "$d days, $h hours, $m minutes, $s seconds";
}

echo seconds2human($seconds);

//output : 1 days, 14 hours, 7 minutes, 47 seconds



No comments:

Post a Comment

Thanks....