CFLib.org – Common Function Library Project

GetEpochTimeFromLocal(DateTime)

Last updated June 21, 2002
Download UDF

author

Rob Brooks-Bilson                                 Rob Brooks-Bilson

Version: 1 | Requires: ColdFusion 5 | Library: DateLib

 
Rated 0 time(s). Average Rating: 0

Description:
Returns the number of seconds since January 1, 1970, 00:00 (Epoch time), with the conversion for the server's offset from GMT factored in. Can be passed a datetime value, or defaults to Now(). Note that epoch time functions are only valid through 2038.

Return Values:
Returns a numeric value.

Example:

<CFOUTPUT>
January 1 1989 14:10:00: #GetEpochTimeFromLocal("January 1 1989 14:10:00")#<BR>
Now(): #GetEpochTimeFromLocal()#<BR>
</CFOUTPUT>

Parameters:

Name Description Required
DateTime Date/time object you want converted to Epoch time. Yes

Full UDF Source:

<cfscript>
/**
* Returns the number of seconds since January 1, 1970, 00:00:00 (Epoch time).
*
* @param DateTime      Date/time object you want converted to Epoch time. (Required)
* @return Returns a numeric value.
* @author Rob Brooks-Bilson (rbils@amkor.com)
* @version 1, June 21, 2002
*/

function GetEpochTimeFromLocal() {
var datetime = 0;
if (ArrayLen(Arguments) eq 0) {
datetime = Now();
}
else {
datetime = arguments[1];
}
return DateDiff("s", DateConvert("utc2Local", "January 1 1970 00:00"), datetime);
}
</cfscript>

Search CFLib.org


Latest Additions

Shawn Porter Shawn Porter added
DeMoronize
3 hour(s) ago

Chris Carey Chris Carey added
readPropertiesFi...
1 day(s) ago

Randy Johnson Randy Johnson added
lastDayofWeek
3 day(s) ago

Frank Marion Frank Marion added
sitemapPing
7 day(s) ago

Top Rated

James Sleeman                                     QuickSort
Rated 5.0, 3 time(s)

Barney Boisvert indentXml
Rated 5.0, 3 time(s)

Nathan Dintenfass                                 queryColumnsToSt...
Rated 5.0, 3 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 3 time(s)

Created by Raymond Camden / Design by Justin Johnson