Link to home
Start Free TrialLog in
Avatar of Lmillard
Lmillard

asked on

Set daylight saving in Coldfusion

Hi,

Hopefully a simple one here. I have an application that on my localhost reports the time correctly, same as the windows box it is on. When I upload it to my live windows server it shows 1 hour behind. I have now code that is trying to be clever for DST. Is this a setting I can tweak as it looks like it isn't using the Windows server time as I expected.

Regards
Leigh
Avatar of _agx_
_agx_
Flag of United States of America image

Is it 1 hr behind because it's using an old JVM - or because the live server uses a different time zone?  Check:

Now: <cfdump var="#now()#">
Time Zone: <cfdump var="#getTimeZoneInfo()#">
CF Version: <cfdump var="#server.coldfusion#">
<cfset version = createObject("java", "java.lang.System").getProperty("java.version")>
Java: <cfdump var="#version#">

If either of those are the issue, then it can only be changed at the server/jvm level. Do you have admin access to the live server?
Avatar of Lmillard
Lmillard

ASKER

Hi,

The live server is in the UK so should be ok and the windows time shows the correct time.

The details from the dumps are as follows,

now() = 14:52

getTimeZoneInfo() =
isDSTon = NO
utcHourOffset = 0
utcMinuteOffset = 0
utcTotalOffset = 0

java: 1.6.0_04

When I compare this to the results on my dev box the getTimeZoneInfo() results are YES, -1,0,-3600

How can I update this?

Thanks
> now() = 14:52

Ok, so the live server is using GMT (no daylight savings time) so those settings look correct.  So what's the "wrong" time you're seeing? Plus or minus one hour?

     > dev box the getTimeZoneInfo() results are YES, -1,0,-3600

So your local box is 1 hr ahead of GMT, correct?

Are your sure it's not your code that's off? What code are you using?

     > How can I update this?

Depends on the source of the problem. It's still not clear yet...
Sorry, being unclear.

My dev box currently shows 16:15 and the CF code correctly uses 16:15
The live box using the same code shows 16:15 and any CF code generates 15:15.

The dev box getTimeZoneInfo() results are YES, -1,0,-3600
The live box getTimeZoneInfo() results are NO, 0,0,0

My dev box is using time correctly as far as I can tell and the live server should be set so that it displays the same getTimeZoneInfo() as the dev one. Just not sure where that function draws its data from and how to update it.
> The live box using the same code shows 16:15 and any CF code generates 15:15.

Well if now() is returning the correct time -16:15 - that strongly suggests your custom CF code is what's wrong.  Can you post the "cf code" that generates 15:15?


> Just not sure where that function draws its data from and how to update it.

IIRC it gets the info from java.util.TimeZone. That can only be changed in the jvm args. But I'm still not sure that's the problem yet...

Edit: Here's how you can check the time zone name
http://www.petefreitag.com/item/132.cfm
I have just added the code from Pete Freitag and both servers are GMT.

It is #now()# which outputs the incorrect time on the live server
> The live server is in the UK so should be ok and the windows time shows the correct time.
> The details from the dumps are as follows,
> now() = 14:52
> dev box shows 16:15
> live box shows 16:15
> It is #now()# which outputs the incorrect time on the live server

Ok .. I'm seeing conflicting reports or I'm not clear which is o/s vs JVM time. To clear up the confusion, can you just post the full results of *all* the tests (from both servers):

----------------
Now: <cfdump var="#now()#"><br>
Time Zone: <cfdump var="#getTimeZoneInfo()#">
CF Version: <cfdump var="#server.coldfusion#">
<cfset version = createObject("java", "java.lang.System").getProperty("java.version")>
Java: <cfdump var="#version#"><br>
<cfset tz = CreateObject("java", "java.util.TimeZone")>
<cfset tz = tz.getDefault()>
TimeZone: <cfdump var="#tz.getDisplayName()# (#tz.getID()#) "><br>

<cfset prop = createObject("java", "java.lang.System").getProperty("user.timezone")>
User.timezone =  <cfdump var="#prop#"><br>
Sure, here you go. See attached image
dateTest.jpg
Can you check one more setting?:"

<cfset prop = createObject("java", "java.lang.System").getProperty("user.timezone")>
User.timezone =  <cfdump var="#prop#"><br>
no problem,

dev server
Java: 1.6.0_14
TimeZone: Greenwich Mean Time (Europe/London)

live server
Java: 1.6.0_04
TimeZone: Greenwich Mean Time (GMT) User.timezone = GMT
I don't see the user.timezone for the DEV server.  If you add a default, what does it say?

<cfset prop = createObject("java", "java.lang.System").getProperty("user.timezone", "NONE")>
User.timezone =  <cfdump var="#prop#"><br>
Development Server
Java: 1.6.0_14
TimeZone: Greenwich Mean Time (Europe/London) User.timezone = Europe/London

Live Server
Java: 1.6.0_04
TimeZone: Greenwich Mean Time (GMT) User.timezone = GMT
BTW: I don't think your dev box is running GMT.  Most of the sites I've checked say the real GMT is now around 4 PM/16:xx, not 5 PM/16:58
Not sure but I presume british summer time is GMT + 1 but it must account for this surely
ASKER CERTIFIED SOLUTION
Avatar of _agx_
_agx_
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
but the dev box is showing the correct time of 17:30 where as the live box is showing 16:30. Wouldn't this make the dev one show 16:30 too?
Yes.  But if you want to use UTC/GMT then the correct time is 16:30 not 17:30.  That means you must change your dev box.

However, if you have admin access to the live server - you can apply the same change, just using "Europe/London" instead of "GMT". Then both boxes will be using "Europe/London" not UTC, and both should report: 17:30.
I have admin access to the server but cannot locate jvm.config, where would this normally be?
It varies based on the install type. For a single server install it's in:

                   C:/ColdFusion8/runtime/jre

I'd recommend trying it on your dev server 1st.  Be sure to make a backup!  jvm.config is a key file.  If you mess it up, the CF server won't start, but if you have a backup, just restore it and everything's good.

Also, be aware the timezone change will affect ALL applications on that JVM. (I don't know if yours is the only app or if there are others...)
Thanks for your help and patience on this one.
After a bit of additional research it turns out the timezone requires was Europe/London as GMT did not adjust for DST
That makes sense. I wasn't sure if you wanted both to use GMT or both to use Europe/London ie GMT +1:00.  In summary, I should've said ... ;-)

Old Time Zone Settings:  
Dev box => Europe/London (GMT+1:00)
Live box => GMT

New Time Zone Settings:
* If you want both machines to use GMT, change the Dev box => GMT.
* If you want both to use "Europe/London", change the Live box => Europe/London