ERuiz Posted October 31, 2007 Share Posted October 31, 2007 Hello guys and gals, How can I convert: $value = 4.51666666667; into hours:minutes? $hours = 4; $minutes = 30; Thanks for the help, as always! Quote Link to comment https://forums.phpfreaks.com/topic/75455-solved-converting-from-decimal-to-hours-and-minutes/ Share on other sites More sharing options...
rajivgonsalves Posted October 31, 2007 Share Posted October 31, 2007 I don't know if there is some function for it in php but here is some of my code $value = 4.50; print floor($value).":".floor(round(str_replace(floor($value).".","0.",$value),2)*60); Quote Link to comment https://forums.phpfreaks.com/topic/75455-solved-converting-from-decimal-to-hours-and-minutes/#findComment-381701 Share on other sites More sharing options...
ERuiz Posted October 31, 2007 Author Share Posted October 31, 2007 I don't know if there is some function for it in php but here is some of my code $value = 4.50; print floor($value).":".floor(round(str_replace(floor($value).".","0.",$value),2)*60); Worked wonderfully! THANKS!!!! Quote Link to comment https://forums.phpfreaks.com/topic/75455-solved-converting-from-decimal-to-hours-and-minutes/#findComment-381703 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.