Last active
December 15, 2015 12:49
-
-
Save tamboer/5263307 to your computer and use it in GitHub Desktop.
Zend_View_Helper_FormatToHourMinutes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class Zend_View_Helper_FormatToHourMinutes extends Zend_View_Helper_Abstract { | |
| function formatToHourMinutes($decTime) { | |
| if(!is_numeric($decTime))return $decTime; | |
| $hour = floor($decTime); | |
| $min = round(60 * ($decTime - $hour)); | |
| if($min !== 60) $time = sprintf('%02d:%02d', $hour, $min); | |
| if($min == 60) $time = sprintf('%02d:%02d', $hour +1, '00');//to counter rounding of .9999999 to 60 minutes | |
| //$time = sprintf('%02d:%02d', $hour, $min); | |
| if ($time == '00:00') | |
| $time = ''; | |
| return $time; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment