CFLib.org – Common Function Library Project

EpochTimeToLocalDate(epoch)

Last updated June 21, 2002

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

 
Rated 0 time(s). Average Rating: 0

Description:
Converts a UNIX epoch time to a ColdFusion date object in local time. Epoch time is defined as the number of seconds elapsed since January 1 1970 00:00:00 GMT. This UDF takes the server's local timezone offset into account when converting from epoch to local time.

Return Values:
Returns a date object.

Example:

view plain print about
<cfoutput>
1021385053: #EpochTimeToLocalDate(1021385053)#<br>
0: #EpochTimeToLocalDate(0)#<br>
</cfoutput>

Parameters:

Name Description Required
epoch Epoch time, in seconds. Yes

Full UDF Source:

view plain print about
<cfscript>
/**
 * Converts Epoch time to a ColdFusion date object in local time.
 * 
 * @param epoch      Epoch time, in seconds. (Required)
 * @return Returns a date object. 
 * @author Rob Brooks-Bilson (rbils@amkor.com) 
 * @version 1, June 21, 2002 
 */

function EpochTimeToLocalDate(epoch) {
  return DateAdd("s",epoch,DateConvert("utc2Local""January 1 1970 00:00"));
}
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Dave Anderson Dave Anderson added
iniToStruct
20 day(s) ago

Dave Anderson Dave Anderson added
deDupeArray
20 day(s) ago

Richard Richard added
dice
22 day(s) ago

Isaac Dealey Isaac Dealey added
getRelative
a while ago

Top Rated

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 22 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Raymond Camden highlightAndCrop
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson