Код: Выделить всё
// Time Clock
function startTime() {
const today = new Date();
let targetTimeZone = 'America/Los_Angeles';
let h = today.getHours();
let m = today.getMinutes();
let s = today.getSeconds();
m = checkTime(m);
s = checkTime(s);
am_pm = "AM";
// Setting time for 12 Hrs format
if (h >= 12) {
if (h > 12) h -= 12;
am_pm = "PM";
} else if (h == 0) {
hr = 12;
am_pm = "AM";
}
// Add Leading Zero's
h = h < 10 ? "0" + h : h;
m = m < 10 ? "0" + m : m;
s = s < 10 ? "0" + s : s;
// Parse Time to Format
document.getElementById('fleet_time').innerHTML = h + ":" + m + ":" + s + " " + am_pm + " PDT";
setTimeout(startTime, 1000);
}
function checkTime(i) {
return i;
}
startTime();< /code>
Подробнее здесь: https://stackoverflow.com/questions/797 ... e-problems
Мобильная версия