“JavaScript -Uhr” Code-Antworten

Wie man eine Uhr in JS macht

function currentTime() {
  let date = new Date(); 
  let hh = date.getHours();
  let mm = date.getMinutes();
  let ss = date.getSeconds();
  let session = "AM";

  if(hh == 0){
      hh = 12;
  }
  if(hh > 12){
      hh = hh - 12;
      session = "PM";
   }

   hh = (hh < 10) ? "0" + hh : hh;
   mm = (mm < 10) ? "0" + mm : mm;
   ss = (ss < 10) ? "0" + ss : ss;
    
   let time = hh + ":" + mm + ":" + ss + " " + session;

  document.getElementById("clock").innerText = time; 
  let t = setTimeout(function(){ currentTime() }, 1000);
}
currentTime();
moi_crn

JavaScript -Uhr

//you can use Timer to do yours clock
	Timer timer=new Timer();
	TimerTask task=new TimerTask(){
	int h=0;
	int s=0;
	public void run(){
		s++;
		if(s==60){
			h++;
			s=0;
			if(h==25){
				h=0;
			}
		}
	}
	};
	 timer.schedule(task,0, 1000);
 timer.schedule(task, 1000);
};
Rockbloster

Ähnliche Antworten wie “JavaScript -Uhr”

Fragen ähnlich wie “JavaScript -Uhr”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen