Jump to content


Javascript Date Object


1 reply to this topic

#1 pizzaboy

    Young Padawan

  • Members
  • Pip
  • 22 posts

Posted 27 November 2005 - 09:42 AM

Hi, does anyone know whether the Javascript Date object is based on the Server time or the Users' Client time?

I'm using the following code to set the time:
var dateObject = new Date()

Basically, I have a few upcoming events occurring on particular dates at set times, which I would like to inform my visitors about. The times are scheduled in GMT, but I would like to display the time according to the user's location and therefore their pc...

I'm aware there is a dateObject.getTimezoneOffset() method I could use, but how can I integrate it? Ideally I would also like to pop-up an alarm, is there any easy way I can utilise the .getTimezoneOffset() method to add/subtract the hours without having to mess about with the actual date?

Thanks for listening (and hopefully for any help)... :ph34r:

#2 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 27 November 2005 - 06:43 PM

I'm no date expert in JavaScript. But i do know 1 thing. It's a CLIENT side language, with out some feature like AJAX, it can't get the server's time (as far as i know).

So in short, Date object = client's time.

And that TimeZoneOffset thingy should do the trick, but i know nothing about it, try googling it.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users