hoursMinutes(minutes)
Last updated July 2, 2008
Version: 2 | Requires: ColdFusion 5 | Library: DateLib
Description:
Formats a number of minutes into "XX hours XX minutes".
Return Values:
Returns a string.
Example:
<cfoutput>
Total cooking time: #HoursMinutes(cookTime)#
</cfoutput>
Parameters:
| Name | Description | Required |
|---|---|---|
| minutes | Number of minutes to convert to hours/minutes. | Yes |
Full UDF Source:
<cfscript>
/**
* Formats a number of minutes into "XX hours XX minutes".
* v2 Charlie Arehart found a bug if hours exactly 2, it said hour, not hours
*
* @param minutes Number of minutes to convert to hours/minutes. (Required)
* @return Returns a string.
* @author Andrew Muller (rebel@daemon.com.au)
* @version 2, July 2, 2008
*/
function hoursMinutes(minutes) {
var tempstr = "";
var strHours = minutes / 60;
var strMinutes = minutes MOD 60;
var hourText = "";
if (strHours gte 1) {
if (strHours gte 2) {
hourText = " hours ";
} else {
hourText = " hour ";
}
tempstr = Fix(strHours) & hourText;
}
if (strMinutes gt 0) {
tempstr = tempstr & strMinutes & " minutes";
}
return tempstr;
}
</cfscript>
Search CFLib.org
Latest Additions
Shawn Porter added
DeMoronize
3 hour(s) ago
Chris Carey added
readPropertiesFi...
1 day(s) ago
Randy Johnson added
lastDayofWeek
3 day(s) ago
Frank Marion added
sitemapPing
7 day(s) ago
Top Rated
QuickSort
Rated 5.0, 3 time(s)
indentXml
Rated 5.0, 3 time(s)
queryColumnsToSt...
Rated 5.0, 3 time(s)
generateSsccAsn
Rated 5.0, 3 time(s)