<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>js获取日期及时间</title>
<script src="../../js/jquery-3.1.1.min.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css">
</head>
<body>
<button onclick="addclick()">获取</button>
</body>
<script type="text/javascript">
function addclick() {
var date = new Date();
alert("今日时间=="+
+date.getFullYear()+"年"//获取完整的年份(4位)
+(date.getMonth()+1)+"月"//获取当前月份(0-11,0代表1月)
+date.getDate()+"日"//获取当前日(1-31)
+date .getDay()+"天"//获取当前星期X(0-6,0代表星期天)
+date.getTime()+"毫秒"//获取当前时间(从1970.1.1开始的毫秒数)
+date.getHours()+"时"//获取当前小时数(0-23)
+date.getMinutes()+"分"//获取当前分钟数(0-59)
+date.getSeconds()+"秒"//获取当前秒数(0-59)
+date.getMilliseconds()+"当前毫秒数========="//获取当前毫秒数(0-999)
+"当前日期:" +date.toLocaleDateString()+//获取当前日期
"当前时间:" +date.toLocaleTimeString()+//获取当前时间
"当前日期+时间:" +date.toLocaleString()//获取当前日期加时间
);
}
</script>
</html>