<!DOCTYPE html> <html> <head> <title>Javascript语法11</title> <meta name="keywords" content="keyword1,keyword2,keyword3"> <meta name="description" content="this is my page"> <meta name="content-type" content="text/html; charset=UTF-8"> </head> <body> <script type="text/javascript"> /* * 演示js中的日期。 Date */ var date = new Date(); with (date) { var year = getFullYear(); var month = getMonth() + 1; var day = getDate(); var week = getWeek(getDay()); document.write(year + "-----" + month + "-----" + day + "-----" + week); } function getWeek(num) { var weeks = [ '星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六' ]; return weeks[num]; } </script> </body> </html>