JsにおけるDate関数のフォーマット変換
668 ワード
function formateDate(date){
var year = date.getFullYear();
var month = date.getMonth()+1;
month = month<10?'0'+month:month;
var day = date.getDate();
day = day<10?'0'+day:day;
var hours = date.getHours();
var min = date.getMinutes();
min = min<10?'0'+min:min;
var ss = date.getSeconds();
return year+'/'+month+'/'+day+" "+hours+":"+min;
}
JavaScript
:document.write(formateDate(new Date()))