www.webdeveloper.com
Results 1 to 4 of 4

Thread: Server Time vs Local Time

  1. #1
    Join Date
    Sep 2010
    Posts
    68

    Server Time vs Local Time

    This example gives the closest server time that you are using:

    var serverTime = new Date();
    var hours = serverTime.getHours();

    I need the local computer time for Timezone calculations:

    var localTime = ?;
    var hours = localTime.getHours();
    Last edited by Philosophaie; 04-06-2014 at 03:50 PM.

  2. #2
    Join Date
    Mar 2005
    Location
    Behind you...
    Posts
    955
    I don't think javascript can get server times. It's a client-side langauge and can only read the user's local time (based on their PC's clock. If their PC clock is wrong so will the javascript time).
    The Date() function always creates a date object based on the user's local computer time.
    "Given billions of tries, could a spilled bottle of ink ever fall into the words of Shakespeare?"

  3. #3
    Join Date
    Aug 2008
    Posts
    40
    You might want to check this link.

    http://www.webdeveloper.com/forum/sh...ing-javascript

    . . .

  4. #4
    Join Date
    Mar 2011
    Posts
    1,144
    The Date() object relies on the user's computer clock, not the server. So you have the local computer time and you can check getGMTOffset or getTimezoneOffset as needed for any conversions.
    Rick Trethewey
    Rainbo Design

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles