search
HomeWeb Front-endBootstrap TutorialDoes bootstrap have a calendar control?

bootstrap has a calendar control, a time and date calendar control, named "datetimepicker". It is a Bootstrap component that can simplify the input of date and time on the page. The datetimepicker control supports date selection and format setting, and supports time period selection control. You only need to use script and link tags to introduce relevant files on the required page to use it.

Does bootstrap have a calendar control?

#The operating environment of this article: Windows7 system, bootstrap3, Dell G3 computer.

Does bootstrap have a calendar control?

bootstrap has a time and date calendar control, named datetimepicker, which is a Bootstrap component that can simplify the input of date and time on the page.

Usage of Bootstrap datetimepicker control

1. Support date selection and format setting

2. Support time selection

3. Support time period selection control

4. Support Chinese

Involved styles and js:

<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.bootcss.com/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.min.css" rel="stylesheet">
 
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>
<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="static/js/moment-with-locales.js"></script>
<script src="https://cdn.bootcss.com/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>

Let’s go directly to the example.

<div class="row">
    <div class=&#39;col-sm-6&#39;>
        <div class="form-group">
            <label>选择日期:</label>
            <!--指定 date标记-->
            <div class=&#39;input-group date&#39; id=&#39;datetimepicker1&#39;>
                <input type=&#39;text&#39; class="form-control" />
                <span class="input-group-addon">
                    <span class="glyphicon glyphicon-calendar"></span>
                </span>
            </div>
        </div>
    </div>
    <div class=&#39;col-sm-6&#39;>
        <div class="form-group">
            <label>选择日期+时间:</label>
            <!--指定 date标记-->
            <div class=&#39;input-group date&#39; id=&#39;datetimepicker2&#39;>
                <input type=&#39;text&#39; class="form-control" />
                <span class="input-group-addon">
                    <span class="glyphicon glyphicon-calendar"></span>
                </span>
            </div>
        </div>
    </div>
</div>
$(function () {
    $(&#39;#datetimepicker1&#39;).datetimepicker({
        format: &#39;YYYY-MM-DD&#39;,
        locale: moment.locale(&#39;zh-cn&#39;)
    });
    $(&#39;#datetimepicker2&#39;).datetimepicker({
        format: &#39;YYYY-MM-DD hh:mm&#39;,
        locale: moment.locale(&#39;zh-cn&#39;)
    });
});
 
 
 
/*4.17版本一些可能用得到的方法参数*/
/*
        showClose:true//是否显示关闭 按钮
        /*viewMode: &#39;days&#39;,//天数模块展示,months则为以月展示
        daysOfWeekDisabled: false,//星期几 禁止选择,参数 [num],多个逗号隔开
        calendarWeeks: false,//显示 周 是 今年第几周
        toolbarPlacement:&#39;default&#39;, //工具摆放的位置,top 则为上,默认为底
        showTodayButton:false,//是否工具栏 显示 直达今天天数的 按钮,默认false
        showClear:false, //是否 工具栏显示  清空 输入框  的按钮。默认false
*/

Screenshot:

Does bootstrap have a calendar control?

## Example of starting time:

<div class="row">
    <div class=&#39;col-sm-6&#39;>
        <div class="form-group">
            <label>选择开始时间:</label>
            <!--指定 date标记-->
            <div class=&#39;input-group date&#39; id=&#39;datetimepicker1&#39;>
                <input type=&#39;text&#39; class="form-control" />
                <span class="input-group-addon">
                    <span class="glyphicon glyphicon-calendar"></span>
                </span>
            </div>
        </div>
    </div>
    <div class=&#39;col-sm-6&#39;>
        <div class="form-group">
            <label>选择结束时间:</label>
            <!--指定 date标记-->
            <div class=&#39;input-group date&#39; id=&#39;datetimepicker2&#39;>
                <input type=&#39;text&#39; class="form-control" />
                <span class="input-group-addon">
                    <span class="glyphicon glyphicon-calendar"></span>
                </span>
            </div>
        </div>
    </div>
</div>
$(function () {
    var picker1 = $(&#39;#datetimepicker1&#39;).datetimepicker({
        format: &#39;YYYY-MM-DD&#39;,
        locale: moment.locale(&#39;zh-cn&#39;),
        //minDate: &#39;2016-7-1&#39;
    });
    var picker2 = $(&#39;#datetimepicker2&#39;).datetimepicker({
        format: &#39;YYYY-MM-DD&#39;,
        locale: moment.locale(&#39;zh-cn&#39;)
    });
    //动态设置最小值
    picker1.on(&#39;dp.change&#39;, function (e) {
        picker2.data(&#39;DateTimePicker&#39;).minDate(e.date);
    });
    //动态设置最大值
    picker2.on(&#39;dp.change&#39;, function (e) {
        picker1.data(&#39;DateTimePicker&#39;).maxDate(e.date);
    });
});

Screenshot:

Does bootstrap have a calendar control?

During initialization, use defaultDate to specify the default time:

 $(&#39;#datetimepicker1&#39;).datetimepicker({
            format: &#39;YYYY-MM-DD&#39;,
            locale: moment.locale(&#39;zh-cn&#39;),
            defaultDate: "1990-1-1"
        });

Of course, you can also use JS code to control the default value of the input box.

Specific example:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width" />
<title>datetimpicker测试</title>
<!--图标样式-->
<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.bootcss.com/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.min.css" rel="stylesheet">
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>
<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdn.bootcss.com/moment.js/2.24.0/moment-with-locales.js"></script>
<script src="https://cdn.bootcss.com/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class=&#39;col-sm-6&#39;>
<div class="form-group">
<label>选择日期:</label>
<!--指定 date标记-->
<div class=&#39;input-group date&#39; id=&#39;datetimepicker1&#39;>
<input type=&#39;text&#39; class="form-control" />
<span class="input-group-addon">
                    <span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
<div class=&#39;col-sm-6&#39;>
<div class="form-group">
<label>选择日期+时间:</label>
<!--指定 date标记-->
<div class=&#39;input-group date&#39; id=&#39;datetimepicker2&#39;>
<input type=&#39;text&#39; class="form-control" />
<span class="input-group-addon">
                    <span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(function() {
$(&#39;#datetimepicker1&#39;).datetimepicker({
format: &#39;YYYY-MM-DD&#39;,
locale: moment.locale(&#39;zh-cn&#39;)
});
$(&#39;#datetimepicker2&#39;).datetimepicker({
format: &#39;YYYY-MM-DD hh:mm&#39;,
locale: moment.locale(&#39;zh-cn&#39;)
});
});
</script>
    </body>
</html>

Does bootstrap have a calendar control?

Recommended: "

bootstrap tutorial"

The above is the detailed content of Does bootstrap have a calendar control?. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
10款好看又实用的Bootstrap后台管理系统模板(快来下载)10款好看又实用的Bootstrap后台管理系统模板(快来下载)Aug 06, 2021 pm 01:55 PM

一个好的网站,不能只看外表,网站后台同样很重要。本篇文章给大家分享10款好看又实用的Bootstrap后台管理系统模板,可以帮助大家快速建立强大有美观的网站后台,欢迎下载使用!如果想要获取更多后端模板,请关注php中文网后端模板栏目!

bootstrap与jquery是什么关系bootstrap与jquery是什么关系Aug 01, 2022 pm 06:02 PM

bootstrap与jquery的关系是:bootstrap是基于jquery结合了其他技术的前端框架。bootstrap用于快速开发Web应用程序和网站,jquery是一个兼容多浏览器的javascript库,bootstrap是基于HTML、CSS、JAVASCRIPT的。

7款实用响应式Bootstrap电商源码模板(快来下载)7款实用响应式Bootstrap电商源码模板(快来下载)Aug 31, 2021 pm 02:13 PM

好看又实用的Bootstrap电商源码模板可以提高建站效率,下面本文给大家分享7款实用响应式Bootstrap电商源码,均可免费下载,欢迎大家使用!更多电商源码模板,请关注php中文网电商源码​栏目!

8款Bootstrap企业公司网站模板(源码免费下载)8款Bootstrap企业公司网站模板(源码免费下载)Aug 24, 2021 pm 04:35 PM

好看又实用的企业公司网站模板可以提高您的建站效率,下面PHP中文网为大家分享8款Bootstrap企业公司网站模板,均可免费下载,欢迎大家使用!更多企业站源码模板,请关注php中文网企业站源码栏目!

bootstrap中sm是什么意思bootstrap中sm是什么意思May 06, 2022 pm 06:35 PM

在bootstrap中,sm是“小”的意思,是small的缩写;sm常用于表示栅格类“.col-sm-*”,是小屏幕设备类的意思,表示显示大小大于等于768px并且小于992px的屏幕设备,类似平板设备。

bootstrap modal 如何关闭bootstrap modal 如何关闭Dec 07, 2020 am 09:41 AM

bootstrap modal关闭的方法:1、连接好bootstrap的插件;2、给按钮绑定模态框事件;3、通过“ $('#myModal').modal('hide');”方法手动关闭模态框即可。

bootstrap默认字体大小是多少bootstrap默认字体大小是多少Aug 22, 2022 pm 04:34 PM

bootstrap默认字体大小是“14px”;Bootstrap是一个基于HTML、CSS、JavaScript的开源框架,用于快速构建基于PC端和移动端设备的响应式web页面,并且默认的行高为“20px”,p元素行高为“10px”。

bootstrap是免费的吗bootstrap是免费的吗Jun 21, 2022 pm 05:31 PM

bootstrap是免费的;bootstrap是美国Twitter公司的设计师“Mark Otto”和“Jacob Thornton”合作基于HTML、CSS、JavaScript 开发的简洁、直观、强悍的前端开发框架,开发完成后在2011年8月就在GitHub上发布了,并且开源免费。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools