[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 852
  • Last Modified:

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
0
Lmillard
Asked:
Lmillard
  • 11
  • 10
1 Solution
 
_agx_Commented:
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?
0
 
LmillardAuthor Commented:
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
0
 
_agx_Commented:
> 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...
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LmillardAuthor Commented:
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.
0
 
_agx_Commented:
> 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
0
 
LmillardAuthor Commented:
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
0
 
_agx_Commented:
> 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>
0
 
LmillardAuthor Commented:
Sure, here you go. See attached image
dateTest.jpg
0
 
_agx_Commented:
Can you check one more setting?:"

<cfset prop = createObject("java", "java.lang.System").getProperty("user.timezone")>
User.timezone =  <cfdump var="#prop#"><br>
0
 
LmillardAuthor Commented:
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
0
 
_agx_Commented:
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>
0
 
LmillardAuthor Commented:
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
0
 
_agx_Commented:
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
0
 
LmillardAuthor Commented:
Not sure but I presume british summer time is GMT + 1 but it must account for this surely
0
 
_agx_Commented:
GMT/UTC doesn't use DST, so it never changes. If you're using something other than GMT/UTC, that would explain the difference.

>  User.timezone = Europe/London

I think that's the problem. The dev box isn't really using GMT.  Try changing it to GMT like the live server.

Make a backup of your "jvm.config" file first (important).  Then add the timezone to the arguments:

       -Duser.timezone=GMT

Save jvm.config and restart CF to apply the changes.
0
 
LmillardAuthor Commented:
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?
0
 
_agx_Commented:
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.
0
 
LmillardAuthor Commented:
I have admin access to the server but cannot locate jvm.config, where would this normally be?
0
 
_agx_Commented:
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...)
0
 
LmillardAuthor Commented:
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
0
 
_agx_Commented:
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
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 11
  • 10
Tackle projects and never again get stuck behind a technical roadblock.
Join Now