CFLib.org – Common Function Library Project

totalTimeFromSec(seconds)

Last updated May 9, 2009

author

Hamlet Javier

Version: 0 | Requires: CF5 | Library: DateLib

Description:
Similar to getTimeFromSeconds, except it's not restricted to 24 hours or less. Function can be used to calculate total duration of time and format it to display as hh:mm:ss

Return Values:
Returns a time object.

Example:

<cfset seconds = 100000>
<cfoutput>#totalTimeFromSec(seconds)#</cfoutput>

Parameters:

Name Description Required
seconds Number of seconds Yes

Full UDF Source:

/**
 * Get total time from seconds in hh:mm:ss format
 * 
 * @param seconds 	 Number of seconds (Required)
 * @return Returns a time object. 
 * @author Hamlet Javier (hamlet@igetspanish.com) 
 * @version 0, May 9, 2009 
 */
function totalTimeFromSec(seconds)
{
	Var xHr = (seconds\3600); // find hour 
	Var xMin = (seconds\60) - (xHr*60); // Find minutes
	Var xSec = seconds - (xHr * 3600) - (xMin*60); // find seconds
	var xTime = "#NumberFormat(xHr,'00')#:#NumberFormat(xMin,'00')#:#NumberFormat(xSec,'00')#"; //return in time format
	return xTime;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson