Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to retrieve the date and time from the server

Status
Not open for further replies.

thelordoftherings

Programmer
May 16, 2004
616
IL
Hello,

How can I retrieve the date and time from the server?
 
I'm not really sure this is a javascript question.....

This is how I do it (using ASP w/ JScript) using a Date object

Code:
<%
   var a = new Date();
   Response.Write("Current Date and Time is : " + a);
%>

-kaht

How much you wanna make a bet I can throw a football over them mountains?
sheepico.jpg
 
But in javascript there is an option to run the script on the server side (runat="Server")
The reason I'm asking it is because I saw this question in a formal Javascript exam and didn't know the answer myself...
 
But in javascript there is an option to run the script on the server side (runat="Server")

Putting runat="server" on your script will not magically make it run on the server - think of the potential security implications that would arise if people could do this!

Server-side code runs on the server, and client-side code runs on the client. It's that simple.

AFAIK, all the runat="server" attribute does, is tell a web server (a .Net one, AFAIK) that form elements should be available for server-side processing.

Perhaps asking this question in a .Net forum might give you a more complrehensive answer.

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top