<html> <head> <meta charset="utf-8"> <title>无标题文档</title> </head> <body> <script> var odate=new Date(); var year=odate.getFullYear(); //获取年 var month=odate.getMonth()+1; //获取月 var date=odate.getDate(); //获取日 var day=odate.getDay(); //获取星期 var hours=odate.getHours(); //获取时钟 var minutes=odate.getMinutes(); //获取分钟 var seconds=odate.getSeconds(); //获取秒 alert('现在时间是:'+year+'年'+month+'月'+date+'日'+hours+'时'+minutes+'分'+seconds+'秒'); </script> </body> </html>