javascript中获取日期方法
1 <!DOCTYPE html> 2 <html> 3 <head lang="en"> 4 <meta charset="UTF-8"> 5 <title>js练习 js是脚本语言直接运行在浏览器上的。</title> 6 <script type="text/javascript"> 7 var nowdate=new Date(); 8 document.writeln(nowdate); 9 var a=nowdate.getFullYear(); 10 var b=nowdate.getMonth(); 11 var c=nowdate.getDate();//返回一个月中的天 12 var d=nowdate.getHours(); 13 var e=nowdate.getMinutes(); 14 var f=nowdate.getSeconds(); 15 var str=a+"-"+b+"-"+c+" "+d+":"+e+":"+f; 16 document.write(str); 17 </script> 18 </head> 19 <body> 20 21 </body> 22 </html>