Jump to content

[SOLVED] Time...


hellouthere

Recommended Posts

Somebody on thtis forum as written me this function for converting hours in the format 00:00:00 into decimal hours

<?php
function timeToHours($time)
{
//Split time into an array
$timeAry = explode (":",$time);

//Convert into a decimal equiv for hours
//Ex: 1:30:00 = 1.5
$hours = 0;
foreach($timeAry as $exp => $value) {
$exp += (3-count($timeAry));
$hours += $value / pow(60,$exp);
}
  return $hours;
}
?>

 

I now need to do the inverse operation (decimal hours --> 00:00:00)

 

could anybody help out?

 

thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/45048-solved-time/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.