ColdFusion UDF Library - TimeHoursHumanFmt
December 16th, 2008
«« Back to ColdFusion Library
Category:
DATE
Description:
Accepts input as hours; converts to human readable format
Parameters:
Returns:
Requires:
Sample Use:
return TimeHoursHumanFmt(7.5); //output: 07Hrs30Mins
Copy to Clipboard
Category:
DATE
Description:
Accepts input as hours; converts to human readable format
Parameters:
- hours (numeric, required)
The number of hours.
Returns:
Requires:
Sample Use:
return TimeHoursHumanFmt(7.5); //output: 07Hrs30Mins
Copy to Clipboard
function TimeHoursHumanFmt(hours){
var hrs = 0;
var mins = 0;
var humanFmt = "";
var negPref = "";
if (hours lt 0){
hours = abs(hours);
negPref = "-";
}
hrs = int(hours);
mins = round((hours - hrs) * 60);
humanFmt = negPref & StringPad(hrs, "right", 2, "0") & "hrs " & StringPad(mins, "right", 2, "0") & "mins";
return humanFmt;
}
// http://www.programmers.org/index.php/coldfusion-udf-library/?ckey=93&function=TimeHoursHumanFmt



