SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: Local Time?

  1. #1
    SitePoint Addict Bloodfest's Avatar
    Join Date
    Feb 2006
    Posts
    229
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Local Time?

    How can I get my application to use the time off os my browser..

    Example-

    Server is in the US .. time is 7:00pm on Monday 13th

    Main Office is in Japan .. time is 10:00am Tuesday 14th

    Branch in Germany .. time is 2:00am Tuesday 14th

    When I have an Employee register at 11:00am in the Japan Office, the time it shows the user registered is 8:00pm.. Is there a way to get NOW() to pull from the browser time... Or is there some sort of Timezone Database I can use to calculate the appropriate times.??

  2. #2
    Take The Blue Pill neilmerton's Avatar
    Join Date
    Jul 2004
    Location
    Leicester, UK
    Posts
    871
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i think 'LSDateFormat' is the way to go:

    http://www.cfquickdocs.com/?getDoc=LSDateFormat

  3. #3
    SitePoint Member rameshsambu's Avatar
    Join Date
    Oct 2006
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lightbulb

    hi bloodfest

    I think you can do either of the three things.

    1) Perhaps you can ask the user while registering the offset to GMT (a +/- value).
    You can store it as a float and use it to display time as for the user. The
    bad thing with this is that most people dont know what this stuff is.

    2) By some method (3 dropdowns are ideal) ask the user what the local time is.
    compare it with the server time, find the offset. This is more practical but
    it is little bit tricky to compute offset considering the crossing of
    International Date Line and Daylight saving hours in many countries.


    3) if you just need to display time of the user who is before the computer
    and if you dont actually need to do any computation based on it, use some
    client side javascript which could show the formatted date of the local
    browser.

    I had to deal with such a situation in my good old days and I somehow
    managed to proceed with the 2nd option.


    -Ramesh

  4. #4
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could also just get the user to input the current time, then calculate the offset yourself.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  5. #5
    SitePoint Addict Bloodfest's Avatar
    Join Date
    Feb 2006
    Posts
    229
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is what I'm trying.. I have Offices in 4 Locations..

    2 in Japan
    2 in Germany

    Look-up table looks like this..

    Code:
    Location                         TimeZone      LocationID
    Okinawa, Japan                15                  1
    Misawa, Japan                 15                  2
    Ramstein, Germany             7                   3
    Berlin, Germany               7                   4
    The number is the diffference in hours from the Server time..

    A user logs in and belongs to one of the locations..

    ie, Okinawa, Japan

    All transactions done by the users that will track by Timestamp with use the following:
    #DateFormat(DateAdd('h',sql_check_timezone.TimeZone,NOW()),'yyyy-mm-dd')#
    #TimeFormat(DateAdd('h',sql_check_timezone.TimeZone,NOW()),'HH:mm:ss')#

    Some users ie, PowerUsers and Admin can switch between locations at any time and will always be in the right time zone..
    I think I may run into problems if there are any daylight savings time..

  6. #6
    SitePoint Guru
    Join Date
    Jul 2005
    Posts
    609
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you know what time zones your users are in, use timezone.cfc:
    http://www.coldfusionusers.com/cfblo...h-timezonecfc/

    Takes care of all that DST stuff for you


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
  •