<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
}
}
這是我的HTML代碼。我是一個總的java noob,並在這裏basiclly發現這個:PHP with javascript code, live clock。我想將格式從「HH:mm:ss GMT + 0100(Romansk(normaltid))」調整爲僅「HH:mm:ss」。
JavaScript不是Java! –