首页 > 其他 > 详细

Datetimepiker 时间选择

时间:2020-08-27 15:22:21      阅读:79      评论:0      收藏:0      [点我收藏+]

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;
		};

Datetimepiker 时间选择

原文:https://www.cnblogs.com/yzm1017/p/13571012.html

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