Friday 7 December 2012

Get Date and Time of Client's Computer Using Javascript


Get Date and Time of Client's Computer Using Javascript


Javascript Function

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


 Call the Javascript Function in the Page as Follows:


    <body onload="displayTime();">
        <form id="form2" runat="server">
        <div id="div1"></div>
        </form>
    </body>


No comments:

Post a Comment

Thank You for Your Comments. We will get back to you soon.

back to top