[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Time

Posted on 2006-04-22
6
Medium Priority
?
168 Views
Last Modified: 2013-12-24
My web host in in USA, but the majority of my web users are in the UK. They post on forums, and so on which are date stamped using NOW(). Obviously the times are taken from the US server.

Is there a command that I can use in application.cfm (set locale manybe), or something I can do to alter all times added to GMT without having to add a line of code to remove the 6 hours from ever date submitted.

The main reason is that eventually I will be moving to a dedicated server in the uK and I dont want to have to find all this code and change back

Thanks
0
Comment
Question by:mvwmail
3 Comments
 
LVL 7

Accepted Solution

by:
wytcom earned 360 total points
ID: 16517011
Use this function to get UTC independent of the location of your host server:

<!---

Name:         GetNISTTime()

Author:         Ben Forta, 12/6/2005

Description:   Obtains current time data from NIST
            Internet Time Service servers.

            DST:      US daylight savings time flag.
            HEALTHY:   TRUE if time server is healthy, FALSE if not.
            JULIAN:      Last 5 digits of Julian date/time value.
            LEAPMONTH:   TRUE is second will be added to or subtracted
                     from the current month.
            MSADV:      Number of milliseconds advanced by server to
                     compensate for network latency.
            NOW:      Current date/time.
            RAW:      Raw data from time server.
            SUCCESS:   TRUE if worked, FALSE if not, check
                     this flag first.

Note:         For a list of NIST time servers see:
            http://tf.nist.gov/timefreq/service/time-servers.html
            Servers should be addressed via IP address rather than
            host name. The server used here is time.nist.gov
            (192.43.244.18), but any of the listed servers will work.
            To use an alternate server, just specify the IP
            address in timeServer variable.
--->

<cffunction name="GetNISTTime" returntype="struct" output="false">
   <cfset var timeServer="192.43.244.18">
   <cfset var result=StructNew()>

   <!--- Try/catch block --->
   <cftry>

      <!--- Try get time data --->
      <cfhttp url="http://#timeServer#:13/" />
      <!--- Save raw data --->
      <cfset result.raw = CFHTTP.FileContent>
      <!--- Extract Julian date --->
      <cfset result.julian=ListGetAt(result.raw, 1, " ")>
      <!--- Extract current date and time --->
      <cfset result.now=ParseDateTime(ListGetAt(result.raw, 2, " ")
                              & " "
                              & ListGetAt(result.raw, 3, " "))>
      <!--- Extract daylight savings time flag --->
      <cfset result.dst=IIf(ListGetAt(result.raw, 4, " ") IS 0,
                        FALSE, TRUE)>
      <!--- Extract leap month flag --->
      <cfset result.leapmonth=IIf(ListGetAt(result.raw, 5, " ") IS 0,
                           FALSE, TRUE)>
      <!--- Extract health flag --->
      <cfset result.healthy=IIf(ListGetAt(result.raw, 6, " ") IS 0,
                           FALSE, TRUE)>
      <!--- Extract advance milliseconds --->
      <cfset result.msadv=ListGetAt(result.raw, 7, " ")>
      <!--- Success --->
      <cfset result.success=TRUE>

      <!--- Catch any errors --->
      <cfcatch type="any">
         <cfset result.success=FALSE>
      </cfcatch>

   </cftry>

   <cfreturn result>

</cffunction>
0
 
LVL 3

Author Comment

by:mvwmail
ID: 16517067
WOAH... gonna have to have a good look at THAT one.. good old Ben F

I suspect that will work.. will try and come back.

Thanks
0
 
LVL 3

Expert Comment

by:pcaioo
ID: 16616676
add follow in application.cfm
<cfset Newnow = dateadd(H,5,now())>( 5 is a example if the server 5 hour slower)
then just use Newnow instead of now()
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
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 anti-spam), the admin…
Loops Section Overview
Suggested Courses

834 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