tags:

views:

48

answers:

3

Hi All, As we all know Javascript is a client side language , means code runs on client side and not on server side.Now what I want to know is that then how come getDate() retrives the server side value.

 var myDate = new Date();
        alert(myDate.getDate());//return current date.
+3  A: 

In your code it doesn't. There is the possibility of setting the Date value with information from the server (ajax, or writing the information to the page on loading) and then it would show the server date. This would obviously require extra code.

Kevin
sorry, not getting.can u pls explain
Wondering
ok got it.Thanks.
Wondering
+2  A: 

This is definitely not the case. Your code will put the current day of the month in an alert box, using the date of the machine you're running the code on (i.e. the client). At least in a web page, anyway. Are you running the code some other way?

Graham Clark
+1  A: 

As others have just said, it really doesn't. It gets the time from the client side system.

Not from the server. Never. Ever. Well... Unless you're browsing from the the server machine...

Oli