Php Codes
Algorithms
Authentication
Calendar
Code Snippets
Content Manage
Cookies
Databases
Date Time
E-Mail
File
Forms
Graphics
HTML and PHP
Look and Feel
MySQL
Searching
Navigation
Statistics
Strings
User Manage
Php > Date Time sample source codes
Convert minutes to hours
Convert minutes to hours <? function m2h($mins) { if ($mins < 0) { $min = Abs($mins); } else { $min = $mins; } $H = Floor($min / 60); $M = ($min - ($H * 60)) / 100; $hours = $H + $M; if ($mins < 0) { $hours = $hours * (-1); } $expl = explode(".", $hours); $H = $expl[0]; if (empty($expl[1])) { $expl[1] = 00; } $M = $expl[1]; if (strlen($M) < 2) { $M = $M . 0; } $hours = $H . "." . $M; return $hours; } ?> Example : <? Echo m2h(120); ?> Will output 2.00 <? Echo m2h(119); ?> Will output 1.59
Privacy Policy
|
Link to Us
|
Links