[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Set daylight saving in Coldfusion

Posted on 2013-06-07
21
Medium Priority
?
829 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

 

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
 
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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
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…
Suggested Courses

649 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