javascript中獲取日期方法
阿新 • • 發佈:2017-06-18
logs .get blog color () tel ear var javascrip
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>
javascript中獲取日期方法