Solved

My host has got his timezone set to something different from mine (i live somewhere across the globe from him).

Posted on 2004-04-23
10
176 Views
Last Modified: 2013-12-24
My host has got his timezone set to something different from mine (i live somewhere across the globe from him).
Is there someway I can control the timezone via <cfml>, instead of having him change the time zone to suit mine?
0
Comment
Question by:lifegauge
[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
  • 3
  • 3
  • 2
  • +1
10 Comments
 
LVL 35

Expert Comment

by:mrichmon
ID: 10902157
You cannot control the timezone of the server using CF.

If you know the difference however, you can just adjsut the time each time you display it.
0
 

Author Comment

by:lifegauge
ID: 10902194
I'm thinking of setting request.mytime in application.cfm and refer to that instead of now() in my pages, but i'm not sure how to find out the difference. my timezone is gmt +8.
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 10902205
And what is their timezone?
0
Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

 
LVL 25

Expert Comment

by:James Rodgers
ID: 10902216
GetTimeZoneInfo() will give you the time on the server and then you can use that with createDateTime to set a variable to match your local time so if the server time offset is 15hrs and you are offset 5 hours the diff is 10 hours so you could try



<cfset myVar=createDateTime(year(now()), month(now()), day(now()), hour(now())-10,minute(now()),second(now()))>

but hour is supposed to be 0-23 so if yuo get a neg number you will need to do some more work to adjust the day then the month then the year

so
<cfset mysec=second(now())>
<cfset mymin=minute(now())>
<cfset myhour=hour(now())-10>
<cfif myhour lt 0>
<cfset myday=day(now())-1>
<cfset myhour=23+myHour>
</cfif>
<cfif myday lt 1>
<cfset mymonth=month(now())-1>
<cfset myday=1>
</cfif>
etc
<cfset mysec=second(now())>
0
 

Author Comment

by:lifegauge
ID: 10985124
This is kinda confusing, I've done it the short way before, just couldn't remember how to get it done therefore I believe there's any easier way to adjust the timezone, does anyone else have other suggestions?
0
 
LVL 2

Expert Comment

by:LeaperJPD
ID: 11000830
Sure, try this:

<!--- get the time zone offset in hours from the server, I call it timez --->
<cfset timez = gettimezoneinfo()>

<!--- set the difference between your time and the server's time --->
<cfset timediff = -4>

<cfoutput>#dateadd("h", timez.utchouroffset+timediff, now())#</cfoutput>
0
 

Author Comment

by:lifegauge
ID: 11015380
Using this:
<!--- get the time zone offset in hours from the server, I call it timez --->
<cfset timez = gettimezoneinfo()>

<!--- set the difference between your time and the server's time --->
<cfset timediff = +8>

<cfset nowtime = #dateadd("h", timez.utchouroffset+timediff, now())#>

<cfoutput>
Current time: #dateformat(now(),'dd-mm-yyyy (HH:mm:ss)')#
<br>
New time: #dateformat(nowtime,'dd-mm-yyyy (HH:mm:ss)')#
</cfoutput>

I am getting this:
Current time: 07-05-2004 (09:05:13)
New time: 07-05-2004 (22:05:13)

The problem is, the current time (my time) is 22:50 and not 22:05.
How do I correct this problem?
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 11015944
So it isn't just a timezone issue then, but also a difference in the set times on the servers that you want to account for?
0
 
LVL 2

Accepted Solution

by:
LeaperJPD earned 125 total points
ID: 11016215
This is not a timezone issue then, the server time is just wrong.  You could adjust for it, but what if the system admin corrects the clock?  But if you really want to..... you can use this:

<!--- get the time zone offset in hours from the server, I call it timez --->
<cfset timez = gettimezoneinfo()>

<!--- set the difference between your time and the server's time --->
<cfset timediff = -4>

<cfset tmpTime = dateadd("h", timez.utchouroffset+timediff, now())>

<cfset smalltimediff = -45>

<cfoutput>#dateadd("n", smalltimediff, tmpTime)#</cfoutput>
0

Featured Post

How our DevOps Teams Maximize Uptime

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

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 setup ssl access to internal local machine 4 127
Problem to get function 52 123
AWS New EC2 Instance and EBS Storage 2 101
Adding multiple JVM environments to RedHat 6 7 81
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

738 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