Solved

Set daylight saving in Coldfusion

Posted on 2013-06-07
21
750 Views
Last Modified: 2013-06-11
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
Comment
Question by:Lmillard
  • 11
  • 10
21 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 39229218
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
 

Author Comment

by:Lmillard
ID: 39229259
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
 
LVL 52

Expert Comment

by:_agx_
ID: 39229301
> 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
 

Author Comment

by:Lmillard
ID: 39229357
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
 
LVL 52

Expert Comment

by:_agx_
ID: 39229447
> 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
 

Author Comment

by:Lmillard
ID: 39229472
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
 
LVL 52

Expert Comment

by:_agx_
ID: 39229496
> 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
 

Author Comment

by:Lmillard
ID: 39229519
Sure, here you go. See attached image
dateTest.jpg
0
 
LVL 52

Expert Comment

by:_agx_
ID: 39229533
Can you check one more setting?:"

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

Author Comment

by:Lmillard
ID: 39229541
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 52

Expert Comment

by:_agx_
ID: 39229555
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
 

Author Comment

by:Lmillard
ID: 39229575
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
 
LVL 52

Expert Comment

by:_agx_
ID: 39229579
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
 

Author Comment

by:Lmillard
ID: 39229603
Not sure but I presume british summer time is GMT + 1 but it must account for this surely
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 39229611
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
 

Author Comment

by:Lmillard
ID: 39229630
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
 
LVL 52

Expert Comment

by:_agx_
ID: 39229642
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
 

Author Comment

by:Lmillard
ID: 39229667
I have admin access to the server but cannot locate jvm.config, where would this normally be?
0
 
LVL 52

Expert Comment

by:_agx_
ID: 39229740
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
 

Author Closing Comment

by:Lmillard
ID: 39236995
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
 
LVL 52

Expert Comment

by:_agx_
ID: 39238017
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to replace a token in a string with square brackets? 2 55
reset email that plugins send alerts to 1 35
.php tree directory? 5 56
Wrapper for APPs 9 37
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This video teaches users how to migrate an existing Wordpress website to a new domain.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now