Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Date() object when using javascript

 
Rudy Rusli
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's say I have a HTML page with a javascript on it:
new Date()

Will it display current date based on where the user opens the browser?

Thanks
- Rudy -
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64851
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What other date would it show?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it will display the date when "new Date()" has been invoked. So if you put it in an onClick handler, it will display the date when the button has been clicked.
 
Rudy Rusli
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> it will display the date when "new Date()" has been invoked. So if you > put it in an onClick handler, it will display the date when the button
> has been clicked.
Hi Satou, thanks for your response.

The reason I asked is because I have a web application that has 3 pages. In first page, I need to display the time based on Pacific timezone. In the second page, I need to display current time based on Central timezone. And in the third page, I need to display the time based on Eastern timezone.

What I need to do is to make sure that wherever a user is (central/ pacific/ eastern), they will see the correct time on each page.

For example:
Let's say now 10 AM Central Time then user should see this no matter where they at in USA:
1st page --> 8 AM Pacific Time.
2nd page --> 10 AM Central Time.
3rd page --> 11 AM Eastern Time.

I'm not sure there's a way to do this using JavaScript since JavaScript is not server-based?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
look at the Daet Object, you will see what you need to use: http://www.w3schools.com/jsref/jsref_obj_date.asp

Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic