문제


나는 초보자이고 도움이 필요합니다.일,시간,분 및 초를 찾는 데 문제가 있습니다.나는 초가 시간과 일에 60 과 동일한에 도달 한 후 분을 업데이트 할 것을 모른다.
나는 일/시간/분/초 형식으로 주어진 날짜로 카운트 다운하려고합니다.
여기 내가 지금까지 한 일의 링크가 있습니다.
미리!:)

도움이 되었습니까?

해결책

나는 당신의 count_execution 기능 및 몇 가지 의견을 추가했습니다.그것은 당신이 물어 무엇을해야한다.

function count_execution() {
  // target date of event
  var eventDate   = new Date(settings.date);
  // now
  var currentDate = new Date();
  // get date diff *in milliseconds*
  var diff   = Math.abs(currentDate - eventDate);

  // compute days left
  // 24h * 60m * 60s * 1000 = 86400000
  var days = Math.floor(diff / 86400000);
  diff = diff % 86400000;

  // compute hours left
  // 60m * 60s * 1000 = 3600000
  var hours = Math.floor(diff / 3600000);
  diff = diff % 3600000;

  // the same for minutes
  var minutes = Math.floor(diff / 60000);
  diff = diff % 60000;

 // finally, seconds
 var seconds = Math.floor(diff / 1000);

 $this.find('#days').text(days);
 $this.find('#hours').text(hours);
 $this.find('#mins').text(minutes);
 $this.find('#secs').text(seconds);
}

희망이 도움이.

다른 팁

var seconds = 1355998990 - new Date().getTime(), // whatever
minutes = Math.floor(seconds/60),
hours = Math.floor(minutes/60),
days = Math.floor(hours/24);

seconds %= 60;
minutes %= 60;
hours %= 24;

console.log("d: " + days + " h: " + hours + " m: " + minutes + " s: " + seconds);
.

은 이것을 할 것입니까?

또한 ;어쩌면 당신은 영감을 얻을 수 있습니다.

트릭을 수행 할 수있는 많은 플러그인 중 하나를 사용하는 이유는 다음 링크를 고려하십시오.

"NoFollow"> http://keith-wood.name/countdown.html

이 하나는 같은 목적을 위해 많은 플러그인을 나열하고, 그 중 하나를 사용하고 미소 짓는다 :) http://www.tripwiremagazine.com/2012/01/jquery-countdown.-scripts.html

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top