Datetimepiker是一个BootStrap的组件,用于实现时间的精确选择。
引用css和js文件
<link rel="stylesheet" href="{% static ‘web/datetimepicker/bootstrapdatetimepicker.min.css‘ %}">
<script src="{% static ‘web/datetimepicker/bootstrapdatetimepicker.min.js‘ %}"></script>    <script src="{% static ‘web/datetimepicker/bootstrapdatetimepicker.zh-CN.js‘ %}"></script
html标签
<input id=‘i1‘ />
应用到标签
$(‘#i1,#i2‘).datetimepicker({    
	language: "zh-CN",    
	minView: "hour",    
	sideBySide: true,    
	format: ‘yyyy-mm-dd hh:ii‘,    
	bootcssVer: 3, 
	startDate: new Date(),    
	autoclose: true 
})
扩展: js中对时间的格式化
Date.prototype.Format = function (fmt) { //author: meizz            
	var o = {
		"M+": this.getMonth() + 1,                
		"d+": this.getDate(), //?                
		"h+": this.getHours(), //??                
		"m+": this.getMinutes(), //?                
		"s+": this.getSeconds(), //?                
		"q+": Math.floor((this.getMonth() + 3) / 3), //??                	  "S": this.getMilliseconds() //??            
		};            
		if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));            			for (var k in o)                
			if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
			return fmt;
		};
原文:https://www.cnblogs.com/yzm1017/p/13571012.html