SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: time zones?

Hybrid View

  1. #1
    SitePoint Addict Garrett's Avatar
    Join Date
    Feb 2001
    Location
    England
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    time zones?

    Hello

    trying to modify a javascript clock script i am using to set the time to be the time in my time zone.

    i know - time = new Date (); is what gets the time
    and i know it is returned like - sun sep 30 01:54:09 utc+0100 2001

    so very simply how do i add the +0100 to make the time correct?

    a+
    Garrett

  2. #2
    ********* obeah makeda's Avatar
    Join Date
    Jun 2001
    Location
    rollin' on dubs
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    here is another way to get the time, try this:

    var oDate = new Date();
    var iHours = oDate.getHours();
    var iMinutes = oDate.getMinutes();
    var iSeconds = oDate.getSeconds();

    var sDate = iHours + ":" + iMinutes + ":" + iSeconds;

    This gets the time from the user's computer, so the time will not be the same throughout different time zones, it will vary depending on the user's clock settings. If you still want to increment or decrement the hours, just do something like this:

    var iHours = oDate.getHours();
    iHours += 1;

  3. #3
    SitePoint Addict Garrett's Avatar
    Join Date
    Feb 2001
    Location
    England
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thats exactly what i don't want! the reason i am using the timezone is because i need to display the time only in France!!

    a+
    Garrett

  4. #4
    ********* obeah makeda's Avatar
    Join Date
    Jun 2001
    Location
    rollin' on dubs
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    why are you trying to do this client side? server side would be a lot easier.

  5. #5
    SitePoint Addict Garrett's Avatar
    Join Date
    Feb 2001
    Location
    England
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yup i know! what i wanted to do initially was get the time with php and then use that to run my javascript clock which is a an continously updating analog type clock, but it seemed like too much grief!

    getting the time is no problem in php, its just i would then have to create some sort of javascript timer (based on a 60 units system of course) which will continually add to the initally taken time so javascripts not my strongpoint i reckon just getting new time() and evaluating my timezone will do have to do.

    if you have an idea on how i could make a function for a timer to do it the first way, i'd greatly appreciate it but otherwise i have no ideas on how to do it that way.

    a+
    Garrett

  6. #6
    ********* obeah makeda's Avatar
    Join Date
    Jun 2001
    Location
    rollin' on dubs
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i see. if i think of something i will post it. good luck!


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
  •