Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
How to get server time from my system ,



pls hepl me,


Thanks in advance
Posted
Comments
Sergey Alexandrovich Kryukov 9-Dec-11 1:48am    
Why not getting server time from server?
--SA
priya from Madras 9-Dec-11 4:47am    
do u know how to get, pls let me know the code

If you want to do this in Asp.Net then you can use Ajax to get Current Time of a Server using JavaScript.

Have a look at below Tip/Trick.

Simplifying Asp.Net Core Ajax
 
Share this answer
 
Comments
priya from Madras 9-Dec-11 4:42am    
ya but it shows my system time instead of server time ,can u pls give me code in javascript
RaisKazi 9-Dec-11 5:09am    
Please refer to above link. It has a exact example to display Server's Time by JavaScript using Ajax.
priya from Madras 9-Dec-11 7:19am    
ya but tat ajax example shows my system time only, i checked
RaisKazi 9-Dec-11 9:13am    
That could be because you are running your application on localhost.
priya from Madras 9-Dec-11 23:45pm    
nice One it was helpful to me ,

Thanks
If you want the server time in Javascript use this code in Page_Load event

Response.Write("<script>var tim='" + DateTime.Now.TimeOfDay.ToString() + "';</script>");
 
Share this answer
 
Comments
priya from Madras 9-Dec-11 7:21am    
divya actually this one is not working
Thanks all,
finally i used lik like this:

C#
function pageLoad(){
   var serverDateTime = new Date('<%= DateTime.Now.ToString() %>');
            alert(serverDateTime);

}
 
Share this answer
 
v2
Create a web service which will return datetime string and deploy it on your server.

From your web app call that service through java script.

I think this will help you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900