2) Then, Where ever you want local time use this code: #zLocalTime# -- MikeR [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => MikerRoo [ip] => webforumsuser@m [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 6 [islastshown] => 1 [isfirstshown] => [attachments] => [allattachments] => ) --> Server time and Local Time Problems - Coldfusion - Advanced Techniques

Server time and Local Time Problems - Coldfusion - Advanced Techniques

Hi I Host my web site in the states but live in Australia. I am getting my time from the server but it something like 12 hours behind. I need to do a date add function or something similar but i need to take into account daylight savings time etc in both countries. Any Ideas ??? Thanks in advance...

  1. #1

    Default Server time and Local Time Problems

    Hi I Host my web site in the states but live in Australia.
    I am getting my time from the server but it something like 12 hours behind.
    I need to do a date add function or something similar but i need to take into
    account daylight savings time etc in both countries.

    Any Ideas ???

    Thanks in advance

    kris Guest

  2. #2

    Default Re: Server time and Local Time Problems

    kris f wrote: 

    maybe this: http://www.sustainablegis.com/projects/tz/testTZCFC.cfm
    PaulH Guest

  3. #3

    Default Re: Server time and Local Time Problems

    That CFC is good but it may be overkill for you.

    Built in CF functions may be enough. See the attached code.

    -- MikeR

    --------------------------------------------------------------------------------
    -----
    ?A good plan violently executed today, is far and away better than a perfect
    plan next week.?
    -- General George S. Patton



    <CFSCRIPT>
    iHoursFromUTC = +11;
    zTmp.Now = Now ();
    zTmp.UTCTime = DateConvert ("local2utc", zTmp.Now);
    zTmp.LocalTime = DateAdd ("h", iHoursFromUTC, zTmp.UTCTime);
    </CFSCRIPT>

    <CFOUTPUT>
    <h3>Hours from UTC = #iHoursFromUTC#</h3>
    <h3>Now (at server) = #zTmp.Now#</h3>
    <h3>UTC Time = #zTmp.UTCTime#</h3>
    <h3>Your local time = #zTmp.LocalTime#</h3>
    </CFOUTPUT>

    MikerRoo Guest

  4. #4

    Default Re: Server time and Local Time Problems

    MikerRoo wrote: 

    no it's not. your code doesn't take into account the differing DST
    start/end dates.
    PaulH Guest

  5. #5

    Default Re: Server time and Local Time Problems

    HI MikerRoo
    just wondering how to implement your CFC do i attach this code to my application.cfm page? and always call the time from there??
    exactly what code do i attach Thanks
    kris Guest

  6. #6

    Default Re: Server time and Local Time Problems

    Hi Kris,

    The CFC was Paul' s post. It had an example of how to use it.
    The CFC is the best way to go.

    I'll show you one alternative to "scare you straight":

    To use the Q&D approach, do the following:
    1) Add this line to your Application.cfm:
    <CFSET Request.iHoursFromUTC = +11> <!--- If your location uses Daylight
    savings, you must change this value twice a year. --->
    2) Then, Where ever you want local time use this code:
    <CFSET zLocalTime = DateAdd ("h", Request.iHoursFromUTC, DateConvert
    ("local2utc", Now()))>
    <CFOUTPUT>#zLocalTime#</CFOUTPUT>

    -- MikeR

    MikerRoo Guest

Similar Threads

  1. Access to UTC time with servers running in local time
    By Michael Mueller in forum Informix
    Replies: 2
    Last Post: August 27th, 05:34 AM
  2. Replies: 2
    Last Post: August 26th, 01:57 AM
  3. Local time on foreign server
    By TomB in forum ASP
    Replies: 3
    Last Post: August 5th, 01:03 AM
  4. Replies: 1
    Last Post: July 9th, 09:46 AM
  5. GMT time to local server time
    By Aaron Bertrand - MVP in forum Microsoft SQL / MS SQL Server
    Replies: 0
    Last Post: July 7th, 06:42 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •