CFLib.org – Common Function Library Project

getSecondsFromTime(timeObject)

Last updated July 16, 2008

author

Alan McCollough

Version: 2 | Requires: CF5 | Library: DateLib

Description:
Returns the total number of seconds from midnight for a valid date/time object.

Return Values:
Returns a numeric value.

Example:

<CFSET TheTime=Now()>

<CFOUTPUT>
Given a time of #TimeFormat(TheTime)#<BR>
#GetSecondsFromTime(TimeFormat(TheTime))# seconds have elapsed since midnight.
<P>
Given a time of #TheTime#<BR>
#GetSecondsFromTime(TheTime)# seconds have elapsed since midnight.
</CFOUTPUT>

Parameters:

Name Description Required
timeObject Valid date/time object. Yes

Full UDF Source:

/**
 * Returns the total number of seconds from midnight for a valid date/time object.
 * Note that this function returns different results depending on whether the date/time object you pass it has seconds defined.
 * 
 * v2 bug fix by Steven Van Gemert
 * 
 * @param timeObject      Valid date/time object. (Required)
 * @return Returns a numeric value. 
 * @author Alan McCollough (kittycat@kittycatonline.com) 
 * @version 2, July 16, 2008 
 */
function getSecondsFromTime(timeObject){
  var theSeconds = Val(Hour(timeObject) * 3600) + Val(Minute(timeObject) * 60) + Second(timeObject);
  return theSeconds;
}

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

Created by Raymond Camden / Design by Justin Johnson