$(document).ready(function() {
function CountdownZ() {
var eventTime = timeStamp;
var startFrom = 'D';
var currentTime = Math.round(new Date().getTime() / 1000);

if (currentTime > eventTime) {
var dayLeft = 0;
var hrLeft = 0;
var minLeft = 0;
var scLeft = 0;
var message = " <i class='fa fa-angle-double-left font12'></i> Timeout";
$(".countdown-z.days").html(dayLeft);
$(".countdown-z.hours").html(hrLeft);
$(".countdown-z.minutes").html(minLeft);
$(".countdown-z.seconds").html(scLeft);
$(".countdown-message").html(message);
}else{

var timeLeft = eventTime - currentTime;
if (startFrom == 'S') {
var scLeft = Math.floor(timeLeft);
$(".countdown-z.seconds").html(scLeft);
}
else if (startFrom == 'M') {
var minLeft = Math.floor(timeLeft / 60);
var scLeft1 = timeLeft - (minLeft * 60);
var scLeft = Math.floor(scLeft1);
$(".countdown-z.minutes").html(minLeft);
$(".countdown-z.seconds").html(scLeft);
}
else if (startFrom == 'H') {
var hrLeft = Math.floor(timeLeft / 60 / 60);
var minLeft1 = hrLeft * 60 * 60;
var minLeft2 = timeLeft - minLeft1;
var minLeft = Math.floor(minLeft2 / 60);
var scLeft1 = minLeft * 60;
var scLeft2 = timeLeft - minLeft1 - scLeft1;
var scLeft = Math.floor(scLeft2);
$(".countdown-z.hours").html(hrLeft);
$(".countdown-z.minutes").html(minLeft);
$(".countdown-z.seconds").html(scLeft);
}
else {
var dayLeft = Math.floor(timeLeft / 60 / 60 / 24);
var hrLeft1 = dayLeft * 24 * 60 * 60;
var hrLeft2 = timeLeft - hrLeft1;
var hrLeft = Math.floor(hrLeft2 / 60 / 60);
var minLeft1 = hrLeft * 60 * 60;
var minLeft2 = timeLeft - hrLeft1 - minLeft1;
var minLeft = Math.floor(minLeft2 / 60);
var scLeft1 = minLeft * 60;
var scLeft2 = timeLeft - hrLeft1 - minLeft1 - scLeft1;
var scLeft = Math.floor(scLeft2);
$(".countdown-z.days").html(dayLeft);
$(".countdown-z.hours").html(hrLeft);
$(".countdown-z.minutes").html(minLeft);
$(".countdown-z.seconds").html(scLeft);
}
}

}
window.onload=CountdownZ;
window.setInterval(CountdownZ, 1000);
});