bootstrap3 时间日期选择器

本文介绍了如何在网页中集成Bootstrap3的时间日期选择器。首先提供了下载CSS和JS文件的链接,然后指导将样式和脚本引入到页面中,确保它们在Bootstrap的基础样式之后。接着,展示了如何在input元素包裹在span或div内,并提供了初始化时间日期选择器的JavaScript代码,包括各种配置选项如是否显示日期、时间、分钟和秒,以及时间步进等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://eonasdan.github.io/bootstrap-datetimepicker/


下载css&js

https://github.com/Eonasdan/bootstrap-datetimepicker


引入CSS

 <link href="/static/css/bootstrap-datetimepicker.min.css" rel="stylesheet">


引入JS

<script src="/static/js/moment.min.js"></script>

<script src="/static/js/bootstrap-datetimepicker.min.js"></script>


datetimepicker css &js 分别放在bootstrap css&js 后面


将input 放到span或div内

            <span class="glyphicon glyphicon-time"></span>
                <label for="start_time">
                    开始时间: 
                </label>
            <span>
                <input id="strtime" data-date-format="YYYY-MM-DD HH:mm:ss" name="strtime" >
            </span>


初始化

 $('#strtime,#endtime').datetimepicker({
            pickDate: true,                 //en/disables the date picker
            pickTime: true,                 //en/disables the time picker
            useMinutes: true,               //en/disables the minutes picker
            useSeconds: true,               //en/disables the seconds picker
            useCurrent: true,               //when true, picker will set the value to the current date/time
            minuteStepping: 1,               //set the minute stepping
            pick12HourFormat: false,
            lang: 'cn'


        });



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值