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;
}
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