Для контекста мне также нужен обратный отсчет, который должен прекратиться после 17:00 по восточному времени.
Код: Выделить всё
$("#Timeremaining").each(function() {
var $this = $(this),
date = new Date(),
usTime = new Date(date.toLocaleString('en-US', {
timeZone: 'America/New_York'
})),
countDownDate = usTime.setHours(16, 59, 59);
var x = setInterval(function() {
var distance = countDownDate - Date.now(),
hours = ('0' + Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))).slice(-2),
minutes = ('0' + Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60))).slice(-2),
$($this).html(hours + " hr " + minutes + " min");
if (distance < 0) {
clearInterval(x);
$('.beforefive').addClass('hide');
$('.afterfive').removeClass('hide');
}
}, 1000);
});Код: Выделить всё
[other text]
Подробнее здесь: https://stackoverflow.com/questions/793 ... -on-mobile