Skip to content


Seconds to Time (HH:MM:SS)

This sections will contains code regarding different PHP & MySQL features and contains help about php/mysql issues.

Seconds to Time (HH:MM:SS)

Postby php developer » May 29th, 2009, 6:50 am

With the help of the below function, you can parse the seconds into a well fromatted time (HH:MM:SS). Just call the function with the parameter seconds and it will return you the time stamp.

Code: Select all
function getTime($iSeconds)
{
   $sHH = str_pad(intval(intval($iSeconds / 3600)), 2, "0", STR_PAD_LEFT);
   $sMM = str_pad(intval(($iSeconds / 60) % 60), 2, "0", STR_PAD_LEFT);
   $sSS = str_pad(intval($iSeconds % 60), 2, "0", STR_PAD_LEFT);

   return ($sHH.":".$sMM.":".$sSS);
}
User avatar
php developer
 
Posts: 53
Joined: July 25th, 2008, 4:56 am

Return to Board index

Return to PHP / MySQL / XML

Who is online

Users browsing this forum: No registered users and 0 guests