0

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.
1
  • It doesn't. What has lead you to think that it does? Commented Jun 23, 2009 at 12:53

3 Answers 3

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

sorry, not getting.can u pls explain
2

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?

Comments

1

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...

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.