 |
|
รบกวนท่านเทพ ๆ เซียน ๆ อธิบายโค้ดนี้ให้ทีครับ ต้นฉบับมันเป็นอังกฤษแปลไม่ออก https://mindgrader.com/tutorials/1-how-to-create-a-simple-javascript-countdown-timer -*-
ขอบคุณครับ
Code (PHP)
<script>
// set the date we're counting down to
var target_date = new Date("Aug 15, 2019").getTime();
// variables for time units
var days, hours, minutes, seconds;
// get tag element
var countdown = document.getElementById("countdown");
// update the tag with id "countdown" every 1 second
setInterval(function () {
// find the amount of "seconds" between now and target
var current_date = new Date().getTime();
var seconds_left = (target_date - current_date) / 1000;
// do some time calculations
days = parseInt(seconds_left / 86400);
seconds_left = seconds_left % 86400;
hours = parseInt(seconds_left / 3600);
seconds_left = seconds_left % 3600;
minutes = parseInt(seconds_left / 60);
seconds = parseInt(seconds_left % 60);
// format countdown string + set tag value
countdown.innerHTML = days + "d, " + hours + "h, " + minutes + "m, " + seconds + "s";
}, 1000);
</script>
Tag : PHP, MySQL, HTML/CSS, JavaScript, Ajax, jQuery
|
ประวัติการแก้ไข 2015-04-30 15:27:24
|
 |
 |
 |
 |
Date :
2015-04-30 15:26:59 |
By :
littlebeer |
View :
1057 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |