-
Notifications
You must be signed in to change notification settings - Fork 0
/
timer.php
117 lines (96 loc) · 2.9 KB
/
timer.php
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
//if you are adding this code to the Wordpress/Woocommerce, delete <?php tag (line 1)
?>
<br><br>
//css part
<style>
//desktop
@media (min-width:500px){
p.Days{
color: #000000;
font-family: "Arial";
font-weight: normal;
font-style: normal;
text-align: center;
font-size: 20px;
margin-top: 1%;
border-style: dotted;
width: 20%;
margin-left: 40%;
}
}
//mobile
@media (max-width:500px){
p.Days{
color: #000000;
font-family: "Arial";
font-weight: normal;
font-style: normal;
text-align: center;
font-size: 20px;
margin-top: 1%;
border-style: dotted;
}
}
div.allCount{
border-style: ridge;
border-width: thin;
}
h2.headDays{
color: #000000;
font-family: "Arial";
text-align: center;
font-weight: 700;
}
button.alisveris {
background-color: #000000;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
margin-bottom: 1%;
}
</style>
//html part
<div class="allCount">
<h2 class="headDays">Next Shipping</h2>
<p class="Days" id="showDays"></p>
</div>
//javascript part
<script>
//code is based on 24 hour-clock system
//shipping time is chosen as 16:00 for days monday-tuesday-wednesday-thursday-friday
//it is restricted such that there will be no shipping on saturday and sunday
var x = setInterval(function()
{
var deliverDays = 0;
var deliverHours = 23;
var deliverMinutes = 59;
var deliverSeconds = 59;
var date = new Date();
var day = date.getDay();
var hour = date.getHours();
var minute = date.getMinutes();
var second = date.getSeconds();
//remaining days are calculating if it is weekend (friday or/and saturday is adding)
if((day == 5 && hour >= 16) || (day == 6 && hour < 16)) deliverDays = 2;
else if((day === 6 && hour >=16) || (day == 0 && hour < 16)) deliverDays = 1;
//remaining time is calculating
if(hour >= 16 ) deliverHours = deliverHours - (hour - 16);
else deliverHours = (15 - hour);
deliverMinutes = 59 - minute;
deliverSeconds = 59 - second;
var show0 = deliverHours + " Hours " + deliverMinutes + " Minutes " + deliverSeconds + " Seconds ";
var show1 = deliverDays + " Days " + deliverHours + " Hours " + deliverMinutes + " Minutes " + deliverSeconds + " Seconds ";
if(deliverDays > 0) document.getElementById("showDays").innerHTML = show1;
else document.getElementById("showDays").innerHTML = show0;
}, 1000);
</script>
<?php
?>
//if you are adding this code to the Wordpress/Woocommerce, delete ?> tag (line 116)