Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date/Time Add

Status
Not open for further replies.

TamedTech

IS-IT--Management
May 3, 2005
998
GB
Hello Guys,

I'm sure a few of you have come accross this issue before so i'm hoping you'll be able to advise the best solution.

I have several processes in my application which are quite time dependant, things like now() statements on query's and scheduled tasks set to run at midnight and things.

However i'm currently with a shared hosting provider that is based in the states so the clock is way out of whack with good old GMT.

How do you overcome this issue? i've thought about using a cfset or somthing in my application that createca variable from a date added now() which i can use on everything.

Any other bright ideas on how to overcome this?

Thanks,

Rob
 
Thanks for this guys,

I ended up just setting some parameters in my application.cfm taking the now() time from the server and then adding 7 hours.

I can then use #application.localtime# and it works a charm.

Thanks,

Rob
 
Watch out for Daylight saving time changes!

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Ah, thats a good point which I hadn't considered, damn WW throwbacks ... ok, i'll have a look at those other suggestions and let you know.

Thanks,

Rob
 
Rob,
How did you go with this issue?? I have a similar problem. The site is hosted in the states but I want my application to use Australian Eastern standard Time. I have had a look at the GetTimeZoneInfo but it seems it only retrieves the time from the which computer it is called. I was hoping there was a function or a way to declare and show the time of a certain Timezone.

Jonas

 
Hey Jonas,

It was quite a hazey area in the end and nobody really had any good answers, since then i've moved the whole opperation in house :) so we're running on a local server and the time is as it should be.

However, as a temporary fix, which unfortunatly doesn't really take into account daylight savings, but at least you only need to make a small mod twice a year.

In my application.cfm I;

<cfset application.time = timeformat(dateadd("h",-7,now()),"HH:mm:ss")>

And you can just modify that -7 to whatever the correct time differance is and then inside your application just call #application.time# anytime you need the correct timestamp. You dont need to use the timeformat() like i have above, but i find i only ever use the time in that format anyway.

Now, for DST i guess you could build in a couple of IF statements, so that is the date is in the eariler part of the year then -7 and if in the later -8 or however DST works out, but i just decided to do it manualy.

I'm sure its not the best solution, but it did for me, so give it a shot.

Rob
 
If you just want GMT then you do not need to take daylight savings into account. Whether it is daylight savings or not, Rudy's suggestion of GetTimeZoneInfo() will work as utcHourOffset is always the offset from GMT.

Check the offset, use DateAdd to apply the difference to the current time and you are left with GMT.

Hope this helps

Wullie

YetiHost - Quality Coldfusion 7/Windows Hosting

The pessimist complains about the wind. The optimist expects it to change. The leader adjusts the sails. - John Maxwell
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top