How can you display server-side Time and Client Side Time in asp.net?

 Posted by Ddd on 1/31/2011 | Category: ASP.NET Interview questions | Views: 9965 | Points: 40
Answer:

Server Side Time:

Write this code:
private void Page_Load(object sender, EventArgs e)
{
Response.Write(DateTime.Now.ToLongTimeString());
}


Client Side Time

<script type="text/javascript">
function abc()
{
var a=new Date();
document.write(a.getHours()+":"+a.getMinutes()+":"+a.getSeconds());
}
abc();

</script>


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response