zoukankan      html  css  js  c++  java
  • Datetimepiker 时间选择

    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;
    		};
    
  • 相关阅读:
    css优化篇
    select超全超详细总结篇
    meta总结
    富文本编辑
    textarea 换行处理
    07 DRF响应类:Response
    06 内部类
    05 序列化组件
    04 APIView的请求生命周期
    python中if __name__ == '__main__'是什么?
  • 原文地址:https://www.cnblogs.com/yzm1017/p/13571012.html
Copyright © 2011-2022 走看看