Last active
August 29, 2015 14:09
-
-
Save danswater/08cbecd8d071d359b22c to your computer and use it in GitHub Desktop.
Timezone
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfcomponent> | |
<cffunction name="conversion" returntype="any" access="remote" > | |
<cfargument name="localDate" type="string" required="true" > | |
<cfargument name="localTimeDiff" type="string" required="true"> | |
<!--- assume the server is in utah ---> | |
<cfset var utahTimeDiff = -7 > | |
<cfset var diff = utahTimeDiff + localTimeDiff > | |
<cfset var convertedDate = DateAdd( "h", diff, localDate ) > | |
<cfset var serverDate = dateFormat( convertedDate, 'd, mmm. yyyy' ) & " - " & timeFormat( convertedDate, 'hh:m:ss' ) > | |
<cfreturn serverDate > | |
</cffunction> | |
<cffunction name="main" returntype="any" access="remote" > | |
<cfset var localDate = Now() > | |
<cfset var localTimeDiff = GetTimeZoneInfo().utcHourOffset > | |
<cfoutput>Local time #dateFormat( localDate, 'd, mmm. yyyy' ) & " - " & timeFormat( localDate, 'hh:m:ss' )#</cfoutput><br /> | |
<cfinvoke method="conversion" returntype="any" returnvariable="arrTimestamp" localDate = #localDate# localTimeDiff = #localTimeDiff# > | |
<cfoutput>Server time #arrTimestamp#</cfoutput> | |
</cffunction> | |
</cfcomponent> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment