<!DOCTYPE html>
<html>
<head>
<title>当前时间</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="static/js/jquery-1.12.4.min.js"></script>
<script type="text/javascript" src="static/js/moment.min.js"></script>
</head>
<body>
<div><span id="ss"></span><br><span id="bb"></span></div>
</body>
<script type="text/javascript">
var time=moment(new Date(),'YYYY-MM-DD HH:mm:ss').add(1,'s'),o;
function refreshClock(){
o = time.add(1,'s').format('YYYY年MM月DD日-dddd HH:mm:ss').split('-');
$('#ss').html(o[0]);
$('#bb').html(o[1]);
};
window.setInterval(refreshClock, 1000);
</script>
</html>
moment使用: //获取服务器当前时间 var now=moment('${.now}','YYYY-MM-DD HH:mm:ss'); var n=now.clone().subtract(1,'days'); //y:当前年 m:当前月 var y=n.year(),m=n.month()+1; //当前月的前十一个月 var n.clone().subtract(11, "months").format("YYYYMM");
百度网盘:链接:https://pan.baidu.com/s/1oAmleLc 密码:o2xu