CFLib.org – Common Function Library Project

toSeconds(time)

Last updated April 25, 2008

author

Todd Sharp

Version: 1 | Requires: CF5 | Library: DateLib

Description:
This will take a duration of time and return the total number of seconds. For example, 4 minutes and 27 seconds would return 267.

Return Values:
Numeric

Example:

<cfdump var="#toSeconds("00:04:27")# />

Parameters:

Name Description Required
time durtion of time desired to convert to seconds Yes

Full UDF Source:

<!---
 Converts a duration of time to seconds.
 
 @param time 	 durtion of time desired to convert to seconds (Required)
 @return Numeric 
 @author Todd Sharp (todd@cfsilence.com) 
 @version 1, April 25, 2008 
--->
<cffunction name="toSeconds" access="public" output="false" returntype="numeric" hint="i take a time value and return the total number of seconds">
	<cfargument name="time" required="true" />
	<cfreturn (hour(arguments.time)*3600) + (minute(arguments.time)*60) + (second(arguments.time)) />
</cffunction>
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