카운트다운을 하고있습니다. 지금은 코드가 아래와같아서 카운트다운 시간을 직접 입력을해야합니다.
저는 현재년도 현재월 현재일등 일자는 자동으로 갱신이되고 시간만 지정하면 해당 지정된시간에 카운트다운이 되길원합니다.
일종의 알람같은거죠 그런데 지금 시간셋팅하느부분에 년도랑 월 일 부분을 현재일로 바꾸면 될거같은데 그게 잘되지않아서 도움을 구합니다. 저는 매일 17:30:00시간까지 카운트 다운되는 알람시계?를 만들고싶습니다.
Copy
/*시간 카운트다운*/
// Set the date we're counting down to
var countDownDate = new Date("Jun 21, 2018 17:30:00").getTime();
// Update the count down every 1 second
var countdownfunction = setInterval(function() {
// Get todays date and time
var now = new Date().getTime();
// Find the distance between now an the count down date
var distance = countDownDate - now;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
// Output the result in an element with id="demo"
document.getElementById("demo").innerHTML = days + "d " + hours + "h "
+ minutes + "m " + seconds + "s ";
// If the count down is over, write some text
if (distance < 0) {
clearInterval(countdownfunction);
document.getElementById("demo").innerHTML = "퇴근완료";
}
}, 1000);
|
답변 1개
채택된 답변
+20 포인트
2018-06-21 (목) 13:14:08
var countDownDate = new Date("<?=date('m/d/Y')." 17:30:00").getTime();
답변을 작성하려면 로그인이 필요합니다.