2020年12月22日星期二

Real time substract times in jave

I need to create timer count done but from value depends on "totalHours" such as if total hours = 2:00:00 resualt = 8:00:00 - 2:00:00 = 6:00:00 i need to count down 6:00:00 every secend

sorry I am very beginner at Javascript

        <tr><td colspan="2" style="border: double 3px groove; border-width: 5px; border-style: outset; text-align: center;">          <asp:Label ID="Label1" runat="server" Text="Hours till last Clock-Out"></asp:Label>          </td>          <td colspan="2" style="border: double 3px groove; border-width: 5px; border-style: outset; text-align: center;">          <asp:Label ID="totalHours" runat="server" Text="hours"></asp:Label>          </td>      </tr>  

this was my tried

            <script type="text/javascript">               function display_c() {                  var refresh = 1000; // Refresh rate in milli seconds                  mytime = setTimeout('display_ct()', refresh)                  mytime = setTimeout('conf()', refresh)                }              function display_ct() {                  var x = new Date()                  x.setHours(x.getHours() + 2);                  var x1 = x.toUTCString();// changing the display to UTC string                  document.getElementById('ct').innerHTML = x1;                  tt = display_c();              }              function conf() {                  var timme = document.getElementById('totalHours').textContent                  var TA = new Date().setHours(8)                  document.getElementById('ct2').innerHTML = timme  // here i can print easy the total hour                  document.getElementById('ct1').innerHTML = TA.getHours() // here i cant fixed 8:00:00 to able to subtarct ??!                  tt = display_c();                }  
https://stackoverflow.com/questions/65418049/real-time-substract-times-in-jave December 23, 2020 at 09:46AM

没有评论:

发表评论