js获取日期:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<div><span id="test">2017654165</span></div>
</body>
<script type="text/javascript" src="https://www.qianduanzhan.com/jquery/3.2.1/jquery.min.js"></script>
<script>
(function($){
var Formatter = function(opt,obj){
var date = new Date(),
yy = date.getFullYear(),
MM = date.getMonth()+1,
DD = date.getDate(),
H = date.getHours(),
M = date.getMinutes(),
S = date.getSeconds(),
fmtdate = opt.fmt.replace(‘yyyy‘,yy)
.replace(‘mm‘,MM)
.replace(‘dd‘,DD)
.replace(‘h‘,H)
.replace(‘m‘,M)
.replace(‘s‘,S);
obj.text(fmtdate);
}
$.fn.formatter = function(opt){
return new Formatter(opt,this)
}
})(jQuery);
$("#test").formatter({fmt:‘yyyy-mm-dd h:m:s‘});
</script>
</html>原文:http://13136447.blog.51cto.com/13126447/1951995