粗略整理,可能存在其他的方式请大家多多指教

选择年份

html

<div class="dropdown">
<label class="search-label">选择年份</label>
<div class="input-daterange input-group">
<input type="text" class="input-sm yearpicker" name="year" />
</div>
</div>

 js 

 $('.yearpicker').datepicker({
startView: 'decade',
minView: 'decade',
format: 'yyyy',
maxViewMode: 2,
minViewMode:2,
autoclose: true
});

只选择月份:

html

<div class="input-group col-md-4">
<span class="input-group-addon">月份</span>
<div class="input-daterange input-group">
<input type="text" class="form-control input-sm monthPicker" name="month12"/>
</div>
</div>

js

$('.monthPicker').datepicker({
language: "zh-CN",
format: 'mm',
autoclose: true,
startView: 'months',
maxViewMode:'months',
minViewMode:'months'
});

  另一种是:亲测有效

 <div class="input-group">
<span class="input-group-addon">月份</span>
<input type="text" class="input-sm form-control monthPicker" name="startTime"/>
</div> $('.monthPicker').datepicker({
language: "zh-CN",
format: "yyyy-mm",
autoclose: true,
startView:2,
minView:2,
maxViewMode:4,
minViewMode:1
});

  另外有几个属性要解释一下:

format

String. 默认值: 'mm/dd/yyyy'

日期格式, p, P, h, hh, i, ii, s, ss, d, dd, m, mm, M, MM, yy, yyyy 的任意组合。

  • p : meridian in lower case ('am' or 'pm') - according to locale file
  • P : meridian in upper case ('AM' or 'PM') - according to locale file
  • s : seconds without leading zeros
  • ss : seconds, 2 digits with leading zeros
  • i : minutes without leading zeros
  • ii : minutes, 2 digits with leading zeros
  • h : hour without leading zeros - 24-hour format
  • hh : hour, 2 digits with leading zeros - 24-hour format
  • H : hour without leading zeros - 12-hour format
  • HH : hour, 2 digits with leading zeros - 12-hour format
  • d : day of the month without leading zeros
  • dd : day of the month, 2 digits with leading zeros
  • m : numeric representation of month without leading zeros
  • mm : numeric representation of the month, 2 digits with leading zeros
  • M : short textual representation of a month, three letters
  • MM : full textual representation of a month, such as January or March
  • yy : two digit representation of a year
  • yyyy : full numeric representation of a year, 4 digits

weekStart

Integer. 默认值:0

一周从哪一天开始。0(星期日)到6(星期六)

startDate

Date. 默认值:开始时间

The earliest date that may be selected; all earlier dates will be disabled.

endDate

Date. 默认值:结束时间

The latest date that may be selected; all later dates will be disabled.

autoclose

Boolean. 默认值:false

当选择一个日期之后是否立即关闭此日期时间选择器。

startView

Number, String. 默认值:2, 'month'

日期时间选择器打开之后首先显示的视图。 可接受的值:

  • 0 or 'hour' for the hour view
  • 1 or 'day' for the day view
  • 2 or 'month' for month view (the default)
  • 3 or 'year' for the 12-month overview
  • 4 or 'decade' for the 10-year overview. Useful for date-of-birth datetimepickers.

minView

Number, String. 默认值:0, 'hour'  1, 'day'  2, 'month'  3,'year'  4 ,'10-year'

日期时间选择器所能够提供的最精确的时间选择视图。

maxView

Number, String. 默认值:4, 'decade' 表示最大的视图 比如最大可以看到10年的视图 最大可以看到一年的视图  如果你设置为年 而你希望开始展示的视图是十年 那么肯定就不行 如果你设置为天  而你希望你的minView是月 那么也肯定是不可以的

日期时间选择器最高能展示的选择范围视图。

bootstrap-datepicker简单使用的更多相关文章

  1. bootstrap datetimepicker、bootstrap datepicker日期组件对范围的简单封装

    1.bootstrap datepicker 使用 <div class="row form-group"> <label class="control ...

  2. bootstrap datepicker含有hasDatepicker无法弹出

    bootstrap datepicker 初始化时,会给控件添加hasDatepicker类 ,如果此时调用 $singleDay.datepicker(initDayOpts);无法弹出时间控件 需 ...

  3. Bootstrap框架 简单使用

    目录 Bootstrap框架 简单使用 什么是Bootstrap 下载 Bootstrap 项目结构 Bootstrap 简单使用 表格格式 Bootstrap 按钮颜色 尺寸 Bootstrap框架 ...

  4. <day006>bootstrap的简单学习 + 轮播图

    任务1:bootstrap的简单学习 <!DOCTYPE html> <html lang="zh-CN"> <head> <meta c ...

  5. (新手向)基于Bootstrap的简单轮播图的手机实现

    个人电脑里存了不少适合手机欣赏的图片,但是放手机里看是件很占据资源的事.鉴于家里有一台电脑经常开着,正好用来做家庭局域网共享,于是笔者就设想通过一种比较简单环保的思路.通过手机访问电脑内的图片. 首先 ...

  6. Bootstrap非常简单实用的web前端开发框架

    今天无意间用firebug看网站的代码发现了Bootstrap,之前从来没有听说过这个东东,于是对它产生了好奇感,通过百度我了解到了Bootstrap是一款非常简单,强悍,实用,移动设备端优先使用的这 ...

  7. require.js+bootstrap实现简单的页面登录和页面跳转

    小颖的这个demo其实很简单的,大家一起来先来看看页面效果图:          目录: 代码: inde.html <!DOCTYPE html> <html> <he ...

  8. bootstrap 一个简单的登陆页面

    效果如图:用bootstrap 写的一个简单的登陆 一.修改样式 样式可以自己调整,例如换个背景色之类的,修改 background-color属性就可以 #from { background-col ...

  9. bootstrap datepicker显示日历

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title> ...

  10. BootStrap实现简单响应式导航菜单

    用BootStrap实现响应式导航栏,我会对其中的一些样式进行说明.   先上代码,是一个很简单的Demo. <!doctype html> <html> <head&g ...

随机推荐

  1. [原创] debian 9.3 搭建Jira+Confluence+Bitbucket项目管理工具(二) -- 安装jira 7.5.4

    [原创] debian 9.3 搭建Jira+Confluence+Bitbucket项目管理工具(二) -- 安装jira 7.5.4 环境都配置好以后, 开始搭建Jira的环境, 这里参考了一篇文 ...

  2. Neural Network Virtual Machine

    深度学习Stack 为什么提出NNVM? 深度学习框架现状 - “碎片化” 目前,深度学习应用框架呈现出高度的“碎片化(fragmentation)”倾向,这主要是由于下述两个原因: 1. 深度学习正 ...

  3. tensorflow安装和初使用

    本文的目的是为了复习并帮助刚开始起步使用机器学习的人员 1.安装准备 为了方便就在window上安装,我的是window10 的笔记本,首先准备python 因为tensorflow在仅仅支持wind ...

  4. CentOS7+CDH5.14.0安装全流程记录,图文详解全程实测-7主节点CM安装子节点Agent配置

    主节点安装cloudera manager 准备工作:下载CM和mysql连接驱动包: CM各版本下载地址:http://archive.cloudera.com/cm5/cm/5/ 从里面选择:ht ...

  5. oralce 的安装以及plsql的配置的html连接

    https://www.cnblogs.com/xkstudy/p/6400738.html

  6. git hub命令,上传到github

    git hub命令,上传到github   1,git  init;      初始化 2,git   config   --global   user.email  " ....@.... ...

  7. MySQL联接查询算法(NLJ、BNL、BKA、HashJoin)

    一.联接过程介绍 为了后面一些测试案例,我们事先创建了两张表,表数据如下:   1 2 3 4 CREATE TABLE t1 (m1 int, n1 char(1)); CREATE TABLE t ...

  8. scrapy 爬取前程无忧

    spider # -*- coding: utf-8 -*- import scrapy from Jobs.items import JobsItem class Job51spiderSpider ...

  9. python脚本执行报错整理

    people = [ {'name':'alex','age':1000}, {'name':'wuxie','age':100}, {'name':'wangcanghai','age':9000} ...

  10. 使用Typescript实现依赖注入(DI)

    前言DI总是和ico相辅相成的,如果想对DI有更多的了解,可以移步我的另一篇文章 依赖注入(DI)和控制反转(IOC),再次我就不多做赘述了. 前几天看见一道面试题,今天借这个话题想跟大家分享一下: ...