fadlyshafa

Untitled

May 5th, 2020
1,834
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function jam_jalan(id_nya){
  2.             var stopwatch = setInterval(function(){
  3.                 angka++;
  4.                 var jam = angka.toString();
  5.                 $('#demo2').text(jam.toHHMMSS());
  6.             },1000);
  7.             return stopwatch;
  8.         }
  9.  
  10.         String.prototype.toHHMMSS = function () {
  11.             var sec_num = parseInt(this, 10); // don't forget the second param
  12.             var hours   = Math.floor(sec_num / 3600);
  13.             var minutes = Math.floor((sec_num - (hours * 3600)) / 60);
  14.             var seconds = sec_num - (hours * 3600) - (minutes * 60);
  15.  
  16.             if (hours   < 10) {hours   = "0"+hours;}
  17.             if (minutes < 10) {minutes = "0"+minutes;}
  18.             if (seconds < 10) {seconds = "0"+seconds;}
  19.             return hours+':'+minutes+':'+seconds;
  20.         }
RAW Paste Data