secondsToEnglish(iSeconds)
Last updated January 21, 2005
Version: 1 | Requires: CF5 | Library: DateLib
Description:
Converts seconds to nearest time unit in english rounding down.
Return Values:
Returns a string.
Example:
<cfoutput>
SecondsToEnglish(1) returns #SecondsToEnglish(1)#<br>
SecondsToEnglish(59) returns #SecondsToEnglish(59)#<br>
SecondsToEnglish(119) returns #SecondsToEnglish(119)#<br>
SecondsToEnglish(600) returns #SecondsToEnglish(600)#<br>
SecondsToEnglish(3600) returns #SecondsToEnglish(3600)#<br>
SecondsToEnglish(86400) returns #SecondsToEnglish(86400)#<br>
</cfoutput>
Parameters:
Name | Description | Required |
---|---|---|
iSeconds | Number of seconds. | Yes |
Full UDF Source:
/**
* Converts seconds to nearest time unit in english.
*
* @param iSeconds Number of seconds. (Required)
* @return Returns a string.
* @author Peter Crowley (pcrowley@webzone.ie)
* @version 1, January 21, 2005
*/
function secondsToEnglish(iSeconds) {
var szPlural = "";
var iTime = "";
var szUpdate = "";
if (iSeconds LTE 0) iSeconds=1;
iTime=iSeconds \ 86400;
if (iTime GT 0) {
if (iTime GT 1) szPlural = 's';
szUpdate = "#iTime# day#szPlural#"; // Days
} else {
iTime=iSeconds \ 3600;
if (iTime GT 0) {
if (iTime GT 1) szPlural = 's';
szUpdate = "#iTime# hour#szPlural#"; // Hours
} else {
iTime=iSeconds \ 60;
if (iTime GT 0) {
if (iTime GT 1) szPlural = 's';
szUpdate = "#iTime# minute#szPlural#"; // Minutes
} else {
iTime=iSeconds;
if (iTime NEQ 1) szPlural = 's';
szUpdate = "#iTime# second#szPlural#"; // Seconds
}
}
}
return szUpdate;
}
Search CFLib.org
Latest Additions
Raymond Camden added
QueryDeleteRows
November 04, 2017
Leigh added
nullPad
May 11, 2016
Raymond Camden added
stripHTML
May 10, 2016
Kevin Cotton added
date2ExcelDate
May 05, 2016
Raymond Camden added
CapFirst
April 25, 2016