1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <script src="jquery-1.3.2.min.js" type="text/javascript"></script> 6 <title></title> 7 <script language="javascript"> 8 function Appendzero (obj) { 9 if (obj < 10) return "0" + obj; else return obj; 10 } 11 function getWeek (weeknum) { 12 if (weeknum == 0) week = "周日"; 13 if (weeknum == 1) week = "周一"; 14 if (weeknum == 2) week = "周二"; 15 if (weeknum == 3) week = "周三"; 16 if (weeknum == 4) week = "周四"; 17 if (weeknum == 5) week = "周五"; 18 if (weeknum == 6) week = "周六"; 19 return week; 20 } 21 function getDateWeek () { 22 var now = new Date (); 23 var year = now.getFullYear ();//获取四位数年数 24 var month = now.getMonth () + 1; 25 var date = now.getDate (); 26 var weeknum = now.getDay (); 27 var hour = now.getHours (); 28 var minute = now.getMinutes (); 29 var second = now.getSeconds (); 30 var s = year + "-" + Appendzero (month) + "-" + Appendzero (date) + " " + Appendzero (hour) + ":" + Appendzero (minute) + ":" + Appendzero (second) + " " + getWeek (weeknum); 31 document.write (s); 32 } 33 getDateWeek (); 34 </script> 35 </head> 36 <body> 37 38 </body> 39 </html>