カテゴリー
log

Javascript:日付表示

function now(){
setTimeout("now()",1000);

var month='JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC';
var now = new Date();
nowDate=digit2(now.getDate());
nowHours=digit2(now.getHours());
nowMinutes=digit2(now.getMinutes());
nowSeconds=digit2(now.getSeconds());

document.getElementById('date').innerHTML=''+month.split(',')[now.getMonth()]+''+nowDate+'.'+now.getFullYear()+' '+nowHours+':'+nowMinutes+':'+nowSeconds;
}

//2ケタ処理
function digit2 (number) {
if (number < 10 ) { number = "0" + number; } return number; }