GetEpochTime([DateTime])
Last updated October 5, 2001
Version: 1 | Requires: ColdFusion 5 | Library: DateLib
Description:
Returns the number of seconds since January 1, 1970, 00:00 (UNIX epoch). 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:
#GetEpochTime("January 1 1989 14:10:00")#<BR>
#GetEpochTime()#<BR>
#GetEpochTime(Now())#
</CFOUTPUT>
Parameters:
| Name | Description | Required |
|---|---|---|
| DateTime | Date/time object you want converted to Epoch time. | No |
Full UDF Source:
<cfscript>
/**
* Returns the number of seconds since January 1, 1970, 00:00:00
*
* @param DateTime Date/time object you want converted to Epoch time.
* @return Returns a numeric value.
* @author Chris Mellon (mellan@mnr.org)
* @version 1, February 21, 2002
*/
function GetEpochTime() {
var datetime = 0;
if (ArrayLen(Arguments) is 0) {
datetime = Now();
}
else {
if (IsDate(Arguments[1])) {
datetime = Arguments[1];
} else {
return NULL;
}
}
return DateDiff("s", "January 1 1970 00:00", datetime);
}
</cfscript>
Search CFLib.org
Latest Additions
Shawn Porter added
DeMoronize
3 hour(s) ago
Chris Carey added
readPropertiesFi...
1 day(s) ago
Randy Johnson added
lastDayofWeek
3 day(s) ago
Frank Marion added
sitemapPing
7 day(s) ago
Top Rated
QuickSort
Rated 5.0, 3 time(s)
indentXml
Rated 5.0, 3 time(s)
queryColumnsToSt...
Rated 5.0, 3 time(s)
generateSsccAsn
Rated 5.0, 3 time(s)