Saturday, March 29, 2014

Get the Current date and Time with the use of J query.

/***********   Get the Current date and Time with the use of J query.  *********** /

<button id="B1">Get the Time</button>
<asp:Label ID="lbltime" runat="server" Text="00:00:00" EnableViewState="true" ></asp:Label>
---------------------------------------------------------------------------------------------------

<script>
      $(document).ready(function () {
          $("#B1").click(function () {
              var dt = new Date();
              //              var time =  dt.getHours() + ":" + dt.getMinutes() + ":" + dt.getSeconds();
              var time = dt.toLocaleDateString() + " " + dt.getHours() + ":" + dt.getMinutes() + ":" + dt.getSeconds();
              $('#<%=lbltime.ClientID%>').html(time);
              alert(time);

          });

      });
</script>


No comments:

Post a Comment