首页 > Web开发 > 详细

js获取日期

时间:2017-07-30 09:57:02      阅读:215      评论:0      收藏:0      [点我收藏+]

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>


js获取日期

原文:http://13136447.blog.51cto.com/13126447/1951995

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!