Created
February 3, 2014 14:07
-
-
Save sugarshin/8784432 to your computer and use it in GitHub Desktop.
カウントダウンタイマー
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
countDown(); | |
}); | |
function countDown() { | |
var startTime = new Date(), | |
endTime = new Date('March 9,2014, 00:00:00'), | |
diff = endTime - startTime, | |
times = 24 * 60 * 60 * 1000, | |
day = Math.floor(diff / times), | |
hour = Math.floor(diff % times / (60 * 60 * 1000)), | |
min = Math.floor(diff % times / (60 * 1000)) % 60, | |
sec = Math.floor(diff % times / 1000) % 60 % 60; | |
// var ms = Math.floor(diff % times / 10) % 100 | |
if (diff > 0) { | |
$('#h').text(day + '日' + hour + '時間' + min + '分' + sec +'秒'); | |
setTimeout('countDown()', 1000); | |
} else { | |
// 処理 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment