Hello,
It would be great that somebody will help me.
I am new in this but I am trying to create a count down shipping clock for my online shop where it will say something like that "Order in the next 2 hours 49 minutes and to ship tomorrow". And I almost made it working. It works on all the days except on Saturday. Please, tell me where did I made a mistake or am I missing something to make it work perfectly. I believe it that it could be done simpler but....
This is the code:
<head>
<script type="text/javascript">
function ord()
{
var h_r = 3;
var dd = new Date();
var ti_h = dd.getHours();
var ti_m = dd.getMinutes();
dd.setDate (dd.getDate() + 1)
var tz = -dd.getTimezoneOffset()/60;
var weekday=new Array(7);
weekday[0]="<strong>SUNDAY<\strong>";
weekday[1]="<strong>MONDAY<\strong>";
weekday[2]="<strong>TUESDAY<\strong>";
weekday[3]="<strong>WEDNESDAY<\strong>";
weekday[4]="<strong>THURSDAY<\strong>";
weekday[5]="<strong>FRIDAY<\strong>";
weekday[6]="<strong>SATURDAY<\strong>";
if (ti_h = - 4 - tz + ti_h)
{
if(ti_h > h_r)
{
var di_t_h = ti_h - h_r;
var di_t_mi = 60 - ti_m;
var h = 11 - di_t_h;
var mi = di_t_mi;
var mess = h + " hours "
var mess1 = mi+" minutes ";
}
}
{if (mess < 0 + " hours ")
{if (weekday[dd.getDay() + 1] != 0)
document.write("Order <strong>NOW</strong> to ship on " + weekday[dd.getDay() + 1] );
else {document.write("Order <strong>NOW</strong> and your order will be shipped on <strong>MONDAY<\strong>");
}}
else {
var da = dd.getDay();
//var da = document.getElementById("da").value;
switch(da)
{
case 1:
case 2:
case 3:
case 4:
case 5:
document.write("Order in the next <br>");
document.write(mess.fontsize(3) );
document.write(mess1.fontsize(3)+ "<br>");
document.write(" for shipping <br> TOMORROW: <br>");
document.write(dd.toLocaleDateString()+ ".");
break;
case 6:
case 7:
document.write("Order <strong>NOW</strong> and your order will be shipped on Monday");
}
}
}
}
ord();
</script>
</head>