JavaScript获取当前时间

<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>

查看原文

原文地址:https://www.cnblogs.com/xinlvtian/p/7929270.html