getTimeFromSeconds(seconds)
Last updated June 19, 2013
Version: 2 | Requires: CF5 | Library: DateLib
Description:
Calculates time from seconds after midnight. The date part of a time variable is set to December 30, 1899
Return Values:
Returns a date/time object.
Example:
<CFSET s=10000>
<cfoutput>
Given s=#s#<BR>
#TimeFormat(GetTimeFromSeconds(s), 'HH:mm:ss')#
</cfoutput>
Parameters:
Name | Description | Required |
---|---|---|
seconds | Number of seconds from midnight used to calculate the time. | Yes |
Full UDF Source:
/**
* Calculates time from seconds after midnight.
* Minor modifications by Rob Brooks-Bilson (rbils@amkor.com).
* v2 by Raymond Camden to support seconds over one day
*
* @param seconds Number of seconds from midnight used to calculate the time. (Required)
* @return Returns a date/time object.
* @author Seth Duffey (sduffey@ci.davis.ca.us)
* @version 2, June 19, 2013
*/
function getTimeFromSeconds(seconds) {
var timehr = "";
var timemin = "";
var timesec = "";
//roll days
if(seconds gt 86400) seconds = seconds-((seconds \ 86400) * 86400);
TimeHr = (((seconds\3600)-1) Mod 24)+1; /* find hour */
TimeMin = seconds\60-(seconds\3600)*60; /* Find minutes */
TimeSec = seconds-(TimeHr * 3600) - (TimeMin*60); /* find seconds */
return createTime(TimeHr,TimeMin,TimeSec); /* Create time (no date) */
}
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