How to get client date time in asp.net

 javascript to implement it.

    <script type=”text/javascript”>
   
    function displayTime()
    {
        var localTime = new Date();
        var year= localTime.getYear();
        var month= localTime.getMonth() +1;
        var date = localTime.getDate();
        var hours = localTime .getHours();
        var minutes = localTime .getMinutes();
        var seconds = localTime .getSeconds();   
        var div=document.getElementById(“div1″);
        div.innerText=year+”-“+month+”-“+date+” “+hours+”:”+minutes+”:”+seconds;
    }
   
    </script>

Then you can display it at web page.

 <body onload=”displayTime();”>
    <form id=”form2″ runat=”server”>
        <div id=”div2″></div>
    </form>
</body>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s