You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.md 17 KiB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. #Bootstrap 3 Datepicker v4 Docs
  2. <div class="alert alert-info">
  3. <strong>Note</strong>
  4. All functions are accessed via the <code>data</code> attribute e.g. <code>$('#datetimepicker').data("DateTimePicker").FUNCTION()</code>
  5. </div>
  6. ### Minimum Setup
  7. <div class="container">
  8. <div class="row">
  9. <div class='col-sm-6'>
  10. <div class="form-group">
  11. <div class='input-group date' id='datetimepicker1'>
  12. <input type='text' class="form-control" />
  13. <span class="input-group-addon">
  14. <span class="glyphicon glyphicon-calendar"></span>
  15. </span>
  16. </div>
  17. </div>
  18. </div>
  19. <script type="text/javascript">
  20. $(function () {
  21. $('#datetimepicker1').datetimepicker();
  22. });
  23. </script>
  24. </div>
  25. </div>
  26. #### Code
  27. ```
  28. <div class="container">
  29. <div class="row">
  30. <div class='col-sm-6'>
  31. <div class="form-group">
  32. <div class='input-group date' id='datetimepicker1'>
  33. <input type='text' class="form-control" />
  34. <span class="input-group-addon">
  35. <span class="glyphicon glyphicon-calendar"></span>
  36. </span>
  37. </div>
  38. </div>
  39. </div>
  40. <script type="text/javascript">
  41. $(function () {
  42. $('#datetimepicker1').datetimepicker();
  43. });
  44. </script>
  45. </div>
  46. </div>
  47. ```
  48. ----------------------
  49. ### Using Locales
  50. <div class="container">
  51. <div class="row">
  52. <div class='col-sm-6'>
  53. <div class="form-group">
  54. <div class='input-group date' id='datetimepicker2'>
  55. <input type='text' class="form-control" />
  56. <span class="input-group-addon">
  57. <span class="glyphicon glyphicon-calendar"></span>
  58. </span>
  59. </div>
  60. </div>
  61. </div>
  62. <script type="text/javascript">
  63. $(function () {
  64. $('#datetimepicker2').datetimepicker({
  65. locale: 'ru'
  66. });
  67. });
  68. </script>
  69. </div>
  70. </div>
  71. #### Code
  72. ```
  73. <div class="container">
  74. <div class="row">
  75. <div class='col-sm-6'>
  76. <div class="form-group">
  77. <div class='input-group date' id='datetimepicker2'>
  78. <input type='text' class="form-control" />
  79. <span class="input-group-addon">
  80. <span class="glyphicon glyphicon-calendar"></span>
  81. </span>
  82. </div>
  83. </div>
  84. </div>
  85. <script type="text/javascript">
  86. $(function () {
  87. $('#datetimepicker2').datetimepicker({
  88. locale: 'ru'
  89. });
  90. });
  91. </script>
  92. </div>
  93. </div>
  94. ```
  95. ----------------------
  96. ### Time Only
  97. <div class="container">
  98. <div class="row">
  99. <div class='col-sm-6'>
  100. <div class="form-group">
  101. <div class='input-group date' id='datetimepicker3'>
  102. <input type='text' class="form-control" />
  103. <span class="input-group-addon">
  104. <span class="glyphicon glyphicon-time"></span>
  105. </span>
  106. </div>
  107. </div>
  108. </div>
  109. <script type="text/javascript">
  110. $(function () {
  111. $('#datetimepicker3').datetimepicker({
  112. format: 'LT'
  113. });
  114. });
  115. </script>
  116. </div>
  117. </div>
  118. #### Code
  119. ```
  120. <div class="container">
  121. <div class="row">
  122. <div class='col-sm-6'>
  123. <div class="form-group">
  124. <div class='input-group date' id='datetimepicker3'>
  125. <input type='text' class="form-control" />
  126. <span class="input-group-addon">
  127. <span class="glyphicon glyphicon-time"></span>
  128. </span>
  129. </div>
  130. </div>
  131. </div>
  132. <script type="text/javascript">
  133. $(function () {
  134. $('#datetimepicker3').datetimepicker({
  135. format: 'LT'
  136. });
  137. });
  138. </script>
  139. </div>
  140. </div>
  141. ```
  142. ----------------------
  143. ### Date Only
  144. <div class="container">
  145. <div class="row">
  146. <div class='col-sm-6'>
  147. <div class="form-group">
  148. <div class='input-group date' id='datetimepicker3'>
  149. <input type='text' class="form-control" />
  150. <span class="input-group-addon">
  151. <span class="glyphicon glyphicon-time"></span>
  152. </span>
  153. </div>
  154. </div>
  155. </div>
  156. <script type="text/javascript">
  157. $(function () {
  158. $('#datetimepicker3').datetimepicker({
  159. format: 'L'
  160. });
  161. });
  162. </script>
  163. </div>
  164. </div>
  165. #### Code
  166. ```
  167. <div class="container">
  168. <div class="row">
  169. <div class='col-sm-6'>
  170. <div class="form-group">
  171. <div class='input-group date' id='datetimepicker3'>
  172. <input type='text' class="form-control" />
  173. <span class="input-group-addon">
  174. <span class="glyphicon glyphicon-time"></span>
  175. </span>
  176. </div>
  177. </div>
  178. </div>
  179. <script type="text/javascript">
  180. $(function () {
  181. $('#datetimepicker3').datetimepicker({
  182. format: 'LT'
  183. });
  184. });
  185. </script>
  186. </div>
  187. </div>
  188. ```
  189. ----------------------
  190. ### No Icon (input field only):
  191. <div class="container">
  192. <div class="row">
  193. <div class='col-sm-6'>
  194. <input type='text' class="form-control" id='datetimepicker4' />
  195. </div>
  196. <script type="text/javascript">
  197. $(function () {
  198. $('#datetimepicker4').datetimepicker();
  199. });
  200. </script>
  201. </div>
  202. </div>
  203. #### Code
  204. ```
  205. <div class="container">
  206. <div class="row">
  207. <div class='col-sm-6'>
  208. <input type='text' class="form-control" id='datetimepicker4' />
  209. </div>
  210. <script type="text/javascript">
  211. $(function () {
  212. $('#datetimepicker4').datetimepicker();
  213. });
  214. </script>
  215. </div>
  216. </div>
  217. ```
  218. ----------------------
  219. ### Enabled/Disabled Dates
  220. <div class="container">
  221. <div class="row">
  222. <div class='col-sm-6'>
  223. <div class="form-group">
  224. <div class='input-group date' id='datetimepicker5'>
  225. <input type='text' class="form-control" />
  226. <span class="input-group-addon">
  227. <span class="glyphicon glyphicon-calendar"></span>
  228. </span>
  229. </div>
  230. </div>
  231. </div>
  232. <script type="text/javascript">
  233. $(function () {
  234. $('#datetimepicker5').datetimepicker({
  235. defaultDate: "11/1/2013",
  236. disabledDates: [
  237. moment("12/25/2013"),
  238. new Date(2013, 11 - 1, 21),
  239. "11/22/2013 00:53"
  240. ]
  241. });
  242. });
  243. </script>
  244. </div>
  245. </div>
  246. #### Code
  247. ```
  248. <div class="container">
  249. <div class="row">
  250. <div class='col-sm-6'>
  251. <div class="form-group">
  252. <div class='input-group date' id='datetimepicker5'>
  253. <input type='text' class="form-control" />
  254. <span class="input-group-addon">
  255. <span class="glyphicon glyphicon-calendar"></span>
  256. </span>
  257. </div>
  258. </div>
  259. </div>
  260. <script type="text/javascript">
  261. $(function () {
  262. $('#datetimepicker5').datetimepicker({
  263. defaultDate: "11/1/2013",
  264. disabledDates: [
  265. moment("12/25/2013"),
  266. new Date(2013, 11 - 1, 21),
  267. "11/22/2013 00:53"
  268. ]
  269. });
  270. });
  271. </script>
  272. </div>
  273. </div>
  274. ```
  275. ----------------------
  276. ### Linked Pickers
  277. <div class="container">
  278. <div class='col-md-5'>
  279. <div class="form-group">
  280. <div class='input-group date' id='datetimepicker6'>
  281. <input type='text' class="form-control" />
  282. <span class="input-group-addon">
  283. <span class="glyphicon glyphicon-calendar"></span>
  284. </span>
  285. </div>
  286. </div>
  287. </div>
  288. <div class='col-md-5'>
  289. <div class="form-group">
  290. <div class='input-group date' id='datetimepicker7'>
  291. <input type='text' class="form-control" />
  292. <span class="input-group-addon">
  293. <span class="glyphicon glyphicon-calendar"></span>
  294. </span>
  295. </div>
  296. </div>
  297. </div>
  298. </div>
  299. <script type="text/javascript">
  300. $(function () {
  301. $('#datetimepicker6').datetimepicker();
  302. $('#datetimepicker7').datetimepicker({
  303. useCurrent: false
  304. });
  305. $("#datetimepicker6").on("dp.change", function (e) {
  306. $('#datetimepicker7').data("DateTimePicker").minDate(e.date);
  307. });
  308. $("#datetimepicker7").on("dp.change", function (e) {
  309. $('#datetimepicker6').data("DateTimePicker").maxDate(e.date);
  310. });
  311. });
  312. </script>
  313. #### Code
  314. ```
  315. <div class="container">
  316. <div class='col-md-5'>
  317. <div class="form-group">
  318. <div class='input-group date' id='datetimepicker6'>
  319. <input type='text' class="form-control" />
  320. <span class="input-group-addon">
  321. <span class="glyphicon glyphicon-calendar"></span>
  322. </span>
  323. </div>
  324. </div>
  325. </div>
  326. <div class='col-md-5'>
  327. <div class="form-group">
  328. <div class='input-group date' id='datetimepicker7'>
  329. <input type='text' class="form-control" />
  330. <span class="input-group-addon">
  331. <span class="glyphicon glyphicon-calendar"></span>
  332. </span>
  333. </div>
  334. </div>
  335. </div>
  336. </div>
  337. <script type="text/javascript">
  338. $(function () {
  339. $('#datetimepicker6').datetimepicker();
  340. $('#datetimepicker7').datetimepicker({
  341. useCurrent: false //Important! See issue #1075
  342. });
  343. $("#datetimepicker6").on("dp.change", function (e) {
  344. $('#datetimepicker7').data("DateTimePicker").minDate(e.date);
  345. });
  346. $("#datetimepicker7").on("dp.change", function (e) {
  347. $('#datetimepicker6').data("DateTimePicker").maxDate(e.date);
  348. });
  349. });
  350. </script>
  351. ```
  352. ----------------------
  353. ### Custom Icons
  354. <div class="container">
  355. <div class="col-sm-6" style="height:130px;">
  356. <div class="form-group">
  357. <div class='input-group date' id='datetimepicker8'>
  358. <input type='text' class="form-control" />
  359. <span class="input-group-addon">
  360. <span class="fa fa-calendar">
  361. </span>
  362. </span>
  363. </div>
  364. </div>
  365. </div>
  366. <script type="text/javascript">
  367. $(function () {
  368. $('#datetimepicker8').datetimepicker({
  369. icons: {
  370. time: "fa fa-clock-o",
  371. date: "fa fa-calendar",
  372. up: "fa fa-arrow-up",
  373. down: "fa fa-arrow-down"
  374. }
  375. });
  376. });
  377. </script>
  378. </div>
  379. #### Code
  380. ```
  381. <div class="container">
  382. <div class="col-sm-6" style="height:130px;">
  383. <div class="form-group">
  384. <div class='input-group date' id='datetimepicker8'>
  385. <input type='text' class="form-control" />
  386. <span class="input-group-addon">
  387. <span class="fa fa-calendar">
  388. </span>
  389. </span>
  390. </div>
  391. </div>
  392. </div>
  393. <script type="text/javascript">
  394. $(function () {
  395. $('#datetimepicker8').datetimepicker({
  396. icons: {
  397. time: "fa fa-clock-o",
  398. date: "fa fa-calendar",
  399. up: "fa fa-arrow-up",
  400. down: "fa fa-arrow-down"
  401. }
  402. });
  403. });
  404. </script>
  405. </div>
  406. ```
  407. ----------------------
  408. ### View Mode
  409. <div class="container">
  410. <div class="col-sm-6" style="height:130px;">
  411. <div class="form-group">
  412. <div class='input-group date' id='datetimepicker9'>
  413. <input type='text' class="form-control" />
  414. <span class="input-group-addon">
  415. <span class="glyphicon glyphicon-calendar">
  416. </span>
  417. </span>
  418. </div>
  419. </div>
  420. </div>
  421. <script type="text/javascript">
  422. $(function () {
  423. $('#datetimepicker9').datetimepicker({
  424. viewMode: 'years'
  425. });
  426. });
  427. </script>
  428. </div>
  429. #### Code
  430. ```
  431. <div class="container">
  432. <div class="col-sm-6" style="height:130px;">
  433. <div class="form-group">
  434. <div class='input-group date' id='datetimepicker9'>
  435. <input type='text' class="form-control" />
  436. <span class="input-group-addon">
  437. <span class="glyphicon glyphicon-calendar">
  438. </span>
  439. </span>
  440. </div>
  441. </div>
  442. </div>
  443. <script type="text/javascript">
  444. $(function () {
  445. $('#datetimepicker9').datetimepicker({
  446. viewMode: 'years'
  447. });
  448. });
  449. </script>
  450. </div>
  451. ```
  452. ----------------------
  453. ### Min View Mode
  454. <div class="container">
  455. <div class="col-sm-6" style="height:130px;">
  456. <div class="form-group">
  457. <div class='input-group date' id='datetimepicker10'>
  458. <input type='text' class="form-control" />
  459. <span class="input-group-addon">
  460. <span class="glyphicon glyphicon-calendar">
  461. </span>
  462. </span>
  463. </div>
  464. </div>
  465. </div>
  466. <script type="text/javascript">
  467. $(function () {
  468. $('#datetimepicker10').datetimepicker({
  469. viewMode: 'years',
  470. format: 'MM/YYYY'
  471. });
  472. });
  473. </script>
  474. </div>
  475. #### Code
  476. ```
  477. <div class="container">
  478. <div class="col-sm-6" style="height:130px;">
  479. <div class="form-group">
  480. <div class='input-group date' id='datetimepicker10'>
  481. <input type='text' class="form-control" />
  482. <span class="input-group-addon">
  483. <span class="glyphicon glyphicon-calendar">
  484. </span>
  485. </span>
  486. </div>
  487. </div>
  488. </div>
  489. <script type="text/javascript">
  490. $(function () {
  491. $('#datetimepicker10').datetimepicker({
  492. viewMode: 'years',
  493. format: 'MM/YYYY'
  494. });
  495. });
  496. </script>
  497. </div>
  498. ```
  499. ----------------------
  500. ### Disabled Days of the Week
  501. <div class="container">
  502. <div class="col-sm-6" style="height:130px;">
  503. <div class="form-group">
  504. <div class='input-group date' id='datetimepicker11'>
  505. <input type='text' class="form-control" />
  506. <span class="input-group-addon">
  507. <span class="glyphicon glyphicon-calendar">
  508. </span>
  509. </span>
  510. </div>
  511. </div>
  512. </div>
  513. <script type="text/javascript">
  514. $(function () {
  515. $('#datetimepicker11').datetimepicker({
  516. daysOfWeekDisabled: [0, 6]
  517. });
  518. });
  519. </script>
  520. </div>
  521. #### Code
  522. ```
  523. <div class="container">
  524. <div class="col-sm-6" style="height:130px;">
  525. <div class="form-group">
  526. <div class='input-group date' id='datetimepicker11'>
  527. <input type='text' class="form-control" />
  528. <span class="input-group-addon">
  529. <span class="glyphicon glyphicon-calendar">
  530. </span>
  531. </span>
  532. </div>
  533. </div>
  534. </div>
  535. <script type="text/javascript">
  536. $(function () {
  537. $('#datetimepicker11').datetimepicker({
  538. daysOfWeekDisabled: [0, 6]
  539. });
  540. });
  541. </script>
  542. </div>
  543. ```
  544. ----------------------
  545. ### Inline
  546. <div style="overflow:hidden;">
  547. <div class="form-group">
  548. <div class="row">
  549. <div class="col-md-8">
  550. <div id="datetimepicker12"></div>
  551. </div>
  552. </div>
  553. </div>
  554. <script type="text/javascript">
  555. $(function () {
  556. $('#datetimepicker12').datetimepicker({
  557. inline: true,
  558. sideBySide: true
  559. });
  560. });
  561. </script>
  562. </div>
  563. #### Code
  564. ```
  565. <div style="overflow:hidden;">
  566. <div class="form-group">
  567. <div class="row">
  568. <div class="col-md-8">
  569. <div id="datetimepicker12"></div>
  570. </div>
  571. </div>
  572. </div>
  573. <script type="text/javascript">
  574. $(function () {
  575. $('#datetimepicker12').datetimepicker({
  576. inline: true,
  577. sideBySide: true
  578. });
  579. });
  580. </script>
  581. </div>
  582. ```