<div id="clock"></div>
<script>
var now = new Date(<?php echo time() * 1000 ?>);
function startInterval(){
setInterval('updateTime();', 1000);
}
startInterval();//start it right away
function updateTime(){
var nowMS = now.getTime();
nowMS += 1000;
now.setTime(nowMS);
var clock = document.getElementById('clock');
if(clock){
clock.innerHTML = now.toTimeString();//adjust to suit
}
}
This is my html code. I am a Java noob and basically found this here: PHP with javascript code, live clock. I want to adjust the format from "HH:mm:ss GMT+0100 (Romansk (normaltid))" to only "HH:mm:ss".
now.toLocaleTimeString(false, {'hour12': false});
or instead of false
- your prefered locale