How to make now() and different timezones get along

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default How to make now() and different timezones get along

    As my title and summary suggest, I just started using the now function, mainly
    for keeping track of when users last logged in. The question is, how can I make
    now work with different timezones. I know that I should have a field that users
    specify what one they are in, then how do I use that with the now() function,
    or something equivilant. Bascially I want to be able to tell what time it is,
    anywhere in the world, easily, once users have specified what time zone they
    are in so I can keep track of the last time they logged in and a few other
    things.

    kenji776 Guest

  2. Similar Questions and Discussions

    1. Converting Time between timezones?
      Hi, ruby comes with the standard unix time conversion functions such as gmtime and localtime. Is there a simple method to convert time into...
    2. Countries and TimeZones
      I want to make a list like http://www.rs-data.at/martin/ausgabe.html. People can enter the data at http://www.rs-data.at/martin/eingabe.html...
    3. [PHP] Timezones and Daylight Savings Time
      What if you set the server to use UTC and then used the clients local system setting to offset it for each client? So the server would have it's...
    4. GNU make & make.pl are dead: long live Perl makepp
      Hi, I have so far not seen the advantage of my 100% Perl syntax - at least not until Emacs learns to syntax highlight the specific parts. Since...
  3. #2

    Default Re: How to make now() and different timezones get along

    see
    [url]http://www.macromedia.com/cfusion/webforums/forum/messageview.cfm?catid=3&thread[/url]
    id=1027652&CFID=145465&CFTOKEN=989eca8c3946cc3f-2B093B57-02FD-D9B2-E90C13A3EF684
    AF3&jsessionid=48304c83e49f7e266472 thread.


    PaulH Guest

  4. #3

    Default Re: How to make now() and different timezones get along

    wow that page that you linked in the thread that you told me to is really cool.
    Just why are there so many timezones? Its crazy! Overall that should probobly
    do what i want it to... if i can figure out how to use that cfc, i havn't
    looked at it yet.Thanks a bunch, hopefully i can get that to work for me.

    kenji776 Guest

  5. #4

    Default Re: How to make now() and different timezones get along

    because politicians control timezones. some places use DST, some don't. soem
    sop/start DST different from surrounding areas. some of the timezones are
    actually historical. also so many are included because its easy for people to
    recognize their city/region rather than a UTC offset, etc.


    PaulH Guest

  6. #5

    Default Re: How to make now() and different timezones get along

    Okay makes sence. Now then, im just a stupid kid trying to code this all, so
    can you maybe give me a quick example on how i would go about using your cfc?
    Say for instance I have a form field called form.timezone, a database field
    called timezone, and a database field called last_logged_in that automatically
    gets set each time someone logs in, using the now() function. How could I
    incorperate your cfc to do what i need it to? Any help here is appreciated.
    Thanks!

    kenji776 Guest

  7. #6

    Default Re: How to make now() and different timezones get along

    first off store your dates (note that you need a datetime not just a time) in a
    single timezone (tz), UTC is usually a good choice.

    <cfset tz=createObject("component","timeZone")> <!--- or wherever the CFC is
    located --->
    <cfquery name="getLogin" datasource="dsn">
    SELECT last_logged_in,timezone
    FROM someTable
    WHERE user='#form.user#'
    </cfquery>

    <cfoutput>
    #dateFormat(tz.castFromUTC(last_logged_in,timezone ))#
    #timeFormat(tz.castFromUTC(last_logged_in,timezone ))#
    </cfoutput>

    PaulH Guest

  8. #7

    Default Re: How to make now() and different timezones get along

    Wow, timezones are confusing. I am suprised cold fusion doesn't have a built in
    way to handle this, or a way to get the time from the users computer or
    something, because this is crazyness. Thanks a bunch paul... but it looks like
    this is a little over my head for the time being.

    kenji776 Guest

  9. #8

    Default Re: How to make now() and different timezones get along

    no, that's not crazy, that's just the way the world is. you might have a look
    at [url]http://www.sustainablegis.com/tips/getClientTZ.cfm[/url]. it only works w/ie 6.0
    and above (though the actual js gateway should be able to work w/firefox,
    etc.).


    PaulH Guest

  10. #9

    Default Re: How to make now() and different timezones get along

    Hmm that does look neat however it doesn't seem to work in firefox. I guess I
    should try and do some more reaserach into how the UTC works before I try and
    do things involving it. BTW you component really looks like it rocks, nice work
    with that, I hope i can figure enough out to be able to use it in my site.
    Again thanks for the help.

    kenji776 Guest

  11. #10

    Default Re: How to make now() and different timezones get along

    as i said i think that gateway should work, just that i wrote that bit for ie. you might contact the author (dan) about the gateway.
    PaulH Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139