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>

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