CFLib.org – Common Function Library Project

LocalTime()

Last updated September 24, 2002

author

chad jackson

Version: 1 | Requires: CF6 | Library: DateLib

Description:
This is a function that behaves just like now() for those running sites where server and local time are different. You just have to set your GMT offset and call the function with localtime() to have the local time displayed.

Return Values:
Returns a date object.

Example:

<cfoutput>#lsDateFormat(localtime(), 'full')# #lsTimeFormat(localtime(),'full')#</cfoutput>

Parameters:

No arguments.

Full UDF Source:

<!---
 Function that returns adjusted local server time.
 
 @return Returns a date object. 
 @author chad jackson (chad@textinc.com) 
 @version 1, September 24, 2002 
--->
<cffunction name="LocalTime" returnType="date" output="false" hint="Returns Local Time">
	<cfset var timeZoneInfo = GetTimeZoneInfo()>
	<!--- local time GMT offset. --->
	<cfset var offset = 9>
	<cfset var GMTtime = DateAdd('s', timeZoneInfo.UTCtotalOffset, Now() )>
	<cfset var theLocalTime = DateAdd('h',offset,GMTtime)>
	<cfreturn theLocaltime>
</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