Jump to content

time to decimal


bolter

Recommended Posts

this works on some level, although may be not that elegant of code, but see if it works for you ...

 

<?
// 12:30:00
$time = '11:49:22';

# strip the seconds
$time = preg_replace('/:[0-9]{2}$/','',$time);

# split hour and minutes
$time_parts = explode(":",$time);

# output hour ... and minutes put into decimal form
echo $time_parts[0] + $time_parts[1] / 60;
?>

Link to comment
https://forums.phpfreaks.com/topic/168102-time-to-decimal/#findComment-886620
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.