webかたつむり ウェブデザインを勉強中 ウェブ初心者のおぼえがき

webかたつむり

WEB制作会社のフォトグラファー

Date(); の復習 / 日付の表示

<body>
<h1 id="now" style="color: red; textalign: center; margin: 0 auto; width: 600px;"></h1>


<script>
function now(){
now = new Date();
year = now.getFullYear()+'年';
month = (now.getMonth()+1)+'月';
date = now.getDate()+'日';
hours = now.getHours()+'時';
minutes = now.getMinutes()+'分';
seconds = now.getSeconds()+'秒';
day = new Array('日曜日',' 月曜日', '火曜日', '水曜日', '木曜日', '金曜日', '土曜日');
jpDay = day[now.getDay()];
document.getElementById('now').textContent = year+month+date+hours+minutes+seconds+jpDay;
}
now();
</script>