-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer.js
More file actions
39 lines (25 loc) · 1017 Bytes
/
timer.js
File metadata and controls
39 lines (25 loc) · 1017 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
var date = new Date(2013, 10, 20, 23, 3, 0, 0); //çàäàåì äàòó ìåñÿö ñ 0
var now = new Date();
var dateDifferenceMS = ( date.getTime() - now.getTime() );
if ( dateDifferenceMS > 0 )
{
setInterval(step, 1000);
}
var $timer = $(".timer");
var $timerDay = $timer.find(".days>p");
var $timerHour = $timer.find(".hours>p");
var $timerMinute = $timer.find(".minutes>p");
var $timerSecond = $timer.find(".seconds>p");
function step()
{
now = new Date();
dateDifferenceMS = (date.getTime() - now.getTime());
var currentDay = Math.floor(dateDifferenceMS/86400000);
var currentHour = Math.floor((dateDifferenceMS - (currentDay*86400000))/3600000);
var currentMinute = Math.floor((dateDifferenceMS - (currentDay*86400000) - (currentHour*3600000))/60000);
var currentSecond = Math.floor(dateDifferenceMS/1000 - (currentDay*86400) - (currentHour*3600) - (currentMinute*60));
$timerDay.text(currentDay);
$timerHour.text(currentHour);
$timerMinute.text(currentMinute);
$timerSecond.text(currentSecond);
}