aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Date() object when using javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Date() object when using javascript" Watch "Date() object when using javascript" New topic
Author

Date() object when using javascript

Rudy Rusli
Ranch Hand

Joined: Jun 01, 2006
Posts: 114
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

Joined: Jan 10, 2002
Posts: 61601
    
  67

What other date would it show?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

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.


[My Blog]
All roads lead to JavaRanch
Rudy Rusli
Ranch Hand

Joined: Jun 01, 2006
Posts: 114
> 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

Joined: Nov 08, 2001
Posts: 15376
    
    6
look at the Daet Object, you will see what you need to use: http://www.w3schools.com/jsref/jsref_obj_date.asp

Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Date() object when using javascript