1 var myDate = new Date();
2 document.write(myDate.getYear().toString()+"<br>"); //获取当前年份(2位)
3 document.write(myDate.getFullYear().toString()+"<br>"); //获取完整的年份(4位,1970-????)
4 document.write(myDate.getMonth().toString()+"<br>"); //获取当前月份(0-11,0代表1月)
5 document.write(myDate.getDate().toString()+"<br>"); //获取当前日(1-31)
6 document.write(myDate.getDay().toString()+"<br>"); //获取当前星期X(0-6,0代表星期天)
7 document.write(myDate.getTime().toString()+"<br>"); //获取当前时间(从1970.1.1开始的毫秒数)
8 document.write(myDate.getHours().toString()+"<br>"); //获取当前小时数(0-23)
9 document.write(myDate.getMinutes().toString()+"<br>"); //获取当前分钟数(0-59)
10 document.write(myDate.getSeconds().toString()+"<br>"); //获取当前秒数(0-59)
11 document.write(myDate.getMilliseconds().toString()+"<br>"); //获取当前毫秒数(0-999)
12 document.write(myDate.toLocaleDateString().toString()+"<br>"); //获取当前日期
2 document.write(myDate.getYear().toString()+"<br>"); //获取当前年份(2位)
3 document.write(myDate.getFullYear().toString()+"<br>"); //获取完整的年份(4位,1970-????)
4 document.write(myDate.getMonth().toString()+"<br>"); //获取当前月份(0-11,0代表1月)
5 document.write(myDate.getDate().toString()+"<br>"); //获取当前日(1-31)
6 document.write(myDate.getDay().toString()+"<br>"); //获取当前星期X(0-6,0代表星期天)
7 document.write(myDate.getTime().toString()+"<br>"); //获取当前时间(从1970.1.1开始的毫秒数)
8 document.write(myDate.getHours().toString()+"<br>"); //获取当前小时数(0-23)
9 document.write(myDate.getMinutes().toString()+"<br>"); //获取当前分钟数(0-59)
10 document.write(myDate.getSeconds().toString()+"<br>"); //获取当前秒数(0-59)
11 document.write(myDate.getMilliseconds().toString()+"<br>"); //获取当前毫秒数(0-999)
12 document.write(myDate.toLocaleDateString().toString()+"<br>"); //获取当前日期