i have this code on my script to show ticking clock
<script type="text/javascript">
function showTime() {
var date = new Date(),
time = new Date(Date.UTC(
date.getFullYear(),
date.getMonth(),
date.getDate(),
date.getHours(),
date.getMinutes(),
date.getSeconds()
));
document.getElementById('time').innerHTML = time.toLocaleTimeString();
}
setInterval(showTime, 1000);
</script>
Anyone know how to change the timezone to a specific timezone like "Asia/Jakarta"
Thanks before!
>Solution :
const timeDisplay = document.getElementById('time');
timeDisplay.textContent = new Date().toLocaleTimeString('ID','Asia/Jakarta')
<p id="time"></p>