日付を表示(new Date, getFullYear, getMonth, getDate, getDay)
<html> <head> <title>日付を表示</title> </head> <body> <script language="JavaScript"> <!-- //曜日の配列を作成 weeks = new Array("日","月","火","水","木","金","土"); //日付の取得 today = new Date(); year = today.getFullYear(); mon = today.getMonth() + 1; date = today.getDate(); day = weeks[today.getDay()]; //日付を表示 document.write(year,"年",mon,"月",date,"日(",day,")"); //--> </script> </body> </html>
〔 実行する 〕