|
Filed Under (PHP Code Samples) by Srikanta on May-17-2007
Code (php) <?php // Function to convert Minutes to Hours : Minutes format function to_hour_string($MM) { $Hour=floor($MM/60); $Min=($MM%60); If($Hour>0) { $str = $Hour."hr"; if ($Hour > 1) $str .= "s"; if ($Min > 0) $str .= " ".$Min."min"; if ($Min > 1) $str .= "s"; } else if ($Min > 0) { $str = " ".$Min."min"; if ($Min > 1) $str .= "s"; } else { $str = "-"; } return $str; } //Example $MM=98; //$MM is Minutes echo to_hour_string($MM); //displays 1hr 38mins ?>
bob on May 19th, 2007 at 9:16 am #
it didn’t work for me (parse error), but the following does the trick: [code] 0) {
bob on May 19th, 2007 at 9:21 am #
can’t post a different (working) function? how lame is that?
Virender on May 19th, 2007 at 10:14 am #
Sorry for the inconveniences caused. We were working on the code highlight plugins for Wordpress. Now the problem should be fixed and our codes should not show any parse errors. Post a comment
|
|