forked from flatpickr/flatpickr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1146 lines (943 loc) · 31.4 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<title>flatpickr - lightweight datetimepicker & calendar</title>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<link rel="icon" type="image/png" href="favicon.png">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, user-scalable=yes">
<script async>
function fp_ready(){
// setting custom defaults
Flatpickr.l10n.firstDayOfWeek = 1;
//Regular flatpickr
document.getElementById("flatpickr-tryme").flatpickr();
document.getElementsByClassName("calendar").flatpickr();
var calendars = document.getElementsByClassName("flatpickr").flatpickr();
var real_selection = document.getElementById("realdate");
document.getElementById("alt")._flatpickr.config.onChange = function(obj, str){
real_selection.textContent = str;
}
document.getElementById("disableRange").flatpickr({
disable: [
{
from: "2016-08-16",
to: "2016-08-19"
},
"2016-08-24",
new Date().fp_incr(30) // 30 days from now
],
minDate: "today"
});
document.getElementById("disableOddDays").flatpickr({
disable: [
function(date) { return date.getDate()%2; } // disable odd days
]
});
document.getElementById("enableNextSeven").flatpickr({
enable: [
{
from: "today",
to: new Date().fp_incr(7)
}
]
});
document.getElementById("enableCustom").flatpickr({
enable: [
function(dateObj){
return dateObj.getDay() %6 !== 0 && dateObj.getFullYear() === 2016;
}
]
});
// Event API
var events = document.getElementById("events");
document.getElementById("events-api-example").flatpickr({
minDate: "today",
enableTime: true,
onChange: function(dateObj, dateStr, fp) {
console.log(fp.selectedDateObj);
events.innerHTML += "<b>onChange</b> (<code>" + dateObj + "</code>, <code>" + dateStr + "</code> )<br>";
events.scrollTop = events.offsetTop;
},
onOpen: function(dateObj, dateStr, fp){
events.innerHTML += "<b>onOpen</b> (<code>" + dateObj + "</code>, <code>" + dateStr + "</code> )<br>";
events.scrollTop = events.offsetTop;
},
onClose: function(dateObj, dateStr, fp){
events.innerHTML += "<b>onClose</b> (<code>" + dateObj + "</code>, <code>" + dateStr + "</code> )<br>";
events.scrollTop = events.offsetTop;
},
onReady: function(dateObj, dateStr, fp){
events.innerHTML += "<b>onReady</b> (<code>" + dateObj + "</code>, <code>" + dateStr + "</code> )<br>";
events.scrollTop = events.offsetTop;
}
});
// Check in/out example
var check_in = document.getElementById("check_in_date").flatpickr({
altInput: true,
altFormat: "\\C\\h\\e\\c\\k \\i\\n\\: l, F j Y",
minDate: new Date()
});
var check_out = document.getElementById("check_out_date").flatpickr({
altInput: true,
altFormat: "\\C\\h\\e\\c\\k \\o\\u\\t: l, F j Y",
minDate: new Date()
});
check_in.config.onChange = function(dateObj) {
check_out.set("minDate", dateObj.fp_incr(1));
};
check_out.config.onChange = function(dateObj) {
check_in.set("maxDate", dateObj.fp_incr(-1));
}
var fiscal = document.getElementById("fiscal").flatpickr({
weekNumbers: true
});
// Fiscal calendar
fiscal.getWeek = function(givenDate){
var checkDate = new Date(givenDate.getTime());
checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
var time = checkDate.getTime();
checkDate.setMonth(7);
checkDate.setDate(28);
var week = (Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 2);
if (week < 1) {
week = 52 + week;
}
return 'FW' + ("0" + week).slice(-2);
}
fiscal.redraw();
// Date format
var fpInstance = new Flatpickr(document.createElement("input")),
formatOutput = document.getElementById("dateFormatOutput"),
now = new Date();
document.getElementById("dateFormatComposer").addEventListener("keyup", function(e){
formatOutput.textContent = fpInstance.formatDate(e.target.value, now);
});
}
</script>
<script async src="dist/flatpickr.js" onload="fp_ready()"></script>
<script async src="assets/prettify.js?skin=none" onload="prettyPrint()"></script>
<script async src="assets/table-of-contents.js"></script>
<script async src="assets/themer.js"></script>
<script async id="locale_script"></script>
<script async src="assets/localizr.js"></script>
<link rel="stylesheet" type="text/css" href="assets/site.css">
<link rel="stylesheet" id=cal_style type="text/css" href="dist/flatpickr.min.css">
</head>
<body>
<div class="flex hero">
<header id=hero>
<h1>flatpickr</h1>
<p class="desc">
A lightweight & powerful datetimepicker
</p>
<div>
<a title="Follow @chmln on GitHub" target="_blank" class="btn" href="https://github.com/chmln">
<i class="icon-github"></i>
<span>Follow</span>
</a>
<a title="Star chmln/flatpickr on GitHub" target="_blank" class="btn" href="https://github.com/chmln/flatpickr">
<i class="icon-star"></i>
<span>Star!</span>
</a>
<a class="btn" href="https://github.com/chmln/flatpickr/archive/gh-pages.zip">
<i class="icon-cloud-down"></i>
<span>Download</span>
</a>
</div>
</header>
</div>
<div class=flex>
<div class="c-l">
<div class='wrapper'>
<div class="example" data-desc="Install" id=install>
<h3>Install</h3>
<div class="alert success">
<h2>NEW: flatpickr v2.0 beta</h2>
<li>Native mobile datetime picker support</li>
<li>SVG icons out-of-the-box</li>
<li>Compatible with jQuery</li>
<li>New datestring parser</li>
<li>Improved performance</li>
<li>Only 6kb minified & gzipped</li>
<li>Not a single dependency</li>
<br>
<code>npm install flatpickr#next</code>
</div>
<p>
<code>npm install flatpickr</code>
<br>
<code>bower install flatpickr-calendar</code>
</p>
<p>Otherwise:<br>
<a class="btn" href="https://github.com/chmln/flatpickr/archive/gh-pages.zip">
<i class="icon-cloud-down"></i>
<span>Download</span>
</a>
</p>
<p class=nomargin>Then <code>require('flatpickr')</code>, use wiredep, or otherwise load the necessary files.</p>
<pre class='prettyprint lang-html' style='clear:both'>
<link rel="stylesheet" type="text/css" href="/path/to/flatpickr.css">
<script src="/path/to/flatpickr.js"></script>
</pre>
</div>
<div class="example" id=syntax>
<h3>Syntax</h3>
<p>There are multiple ways to create a Flatpickr instance. In all cases, config is optional. The return value will be the Flatpickr instance, or an array of instances.</p>
<pre class='prettyprint lang-js'>
document.getElementsByClassName("myClass").flatpickr({..config});
document.getElementById("myID").flatpickr();
$(".calendar").flatpickr(); // jQuery
</pre>
<hr>
<p>Or pass in a node directly.</p>
<pre class='prettyprint lang-js'>
new Flatpickr(HTMLElement, [options]);
</pre>
</div>
<div class="example" data-desc="A basic datepicker" id="basic">
<h3>Basics</h3>
<p><strong>A basic datepicker</strong></p>
<p>
<input id="flatpickr-tryme" placeholder="Try me..">
</p>
</div>
<div class="example" data-desc="Custom date/time formats" id="format">
<h3>Date Formatting</h3>
<p>Using <a href=#options>dateFormat</a></p>
<pre class='prettyprint lang-html'>
<input class=flatpickr data-date-format="d-m-Y">
<input class=flatpickr data-date-format="m/d/Y">
<input class=flatpickr data-date-format="l, F j, Y">
</pre>
<p>
<input class=flatpickr data-date-format="d-m-Y" placeholder="European Format ('d-m-Y')">
</p>
<p>
<input class=flatpickr data-date-format="m/d/Y" placeholder="American Format ('m/d/Y')">
</p>
<p>
<input class=flatpickr data-date-format="l, F j, Y" placeholder="Fancy Textual Format ('l, F j, Y')">
</p>
</div>
<div class="example" data-desc="Datetimepicker" id="datetimepicker">
<h3>DateTime Picker</h3>
<pre class='prettyprint lang-html'>
<input class=flatpickr data-enable-time=true>
</pre>
<p>
<input class=flatpickr data-enable-time=true placeholder="Pick date and time">
</p>
<br>
<h4>DateTime Picker: 24 Hour Mode</h4>
<pre class='prettyprint lang-html'>
<input class=flatpickr data-enable-time=true data-time_24hr=true>
</pre>
<p>
<input class=flatpickr data-enable-time=true data-time_24hr=true placeholder="24 hour time">
</p>
<br>
<h4>DateTime Picker with seconds</h4>
<pre class='prettyprint lang-html'>
<input class=flatpickr data-enable-time=true data-enable-seconds=true >
</pre>
<p>
<input class=flatpickr data-enable-time=true data-enable-seconds=true placeholder="Pick date and time">
</p>
</div>
<div class="example" data-desc="Time Picker" id="timepicker">
<h3>Time Picker</h3>
<pre class='prettyprint lang-html'>
<input class=flatpickr data-enable-time=true data-enable-seconds=true data-no-calendar=true value="09:01:45">
<input class=flatpickr data-enable-time=true data-enable-seconds=true data-no-calendar=true value="09:01:30 PM">
</pre>
<input class=flatpickr data-enable-time=true data-enable-seconds=true data-no-calendar=true placeholder="Pick time" value="09:01:45">
<input class=flatpickr data-enable-time=true data-enable-seconds=true data-no-calendar=true placeholder="Pick time" value="09:01:30 PM">
</div>
<div class="example" data-desc="Date Limits (maxDate/minDate)" id="maxmindate">
<h3>Date Limits - minDate and maxDate</h3> The example below conveniently uses data-attributes for setting
<strong>minDate</strong> and <strong>maxDate</strong> <a href=#options>options</a>.
<pre class="prettyprint lang-html">
<input class=flatpickr data-min-date=today>
<input class=flatpickr data-min-date="2016-09-20">
<input class=flatpickr data-min-date="September 2, 2015">
<input class=flatpickr data-min-date=today data-max-date='2016-8-20'>
</pre>
<p>
<input class=flatpickr data-min-date=today placeholder="minDate: today">
</p>
<p>
<input class=flatpickr data-min-date="2016-09-20" placeholder="minDate: '2016-09-20'">
</p>
<p>
<input class=flatpickr data-min-date="2015/09/02" placeholder="minDate: '2015/09/02'">
</p>
<p>
<input class=flatpickr data-min-date=today data-max-date='2016-8-20' placeholder="minDate: today, maxDate: '2016-8-20'">
</p>
</div>
<div class="example" data-desc="User-Friendly date output" id="altinput">
<h3>Human-friendly Date Output</h3>
<p>altInput can be used for displaying a friendly date format (per <code>altFormat</code>) to the user while sending the date formatted as <code>dateFormat</code> to the server. Feel free to inspect the input element below after picking a date to see what's going on. </p>
<pre class='prettyprint lang-html'>
<input class=flatpickr data-alt-input=true data-alt-format="F j, Y">
</pre>
<p>
<input class=flatpickr id="alt" data-alt-input=true data-alt-format="F j, Y" placeholder="The real input is hidden :^)">
</p>
<p><strong>Selected date</strong>: <span id=realdate>nothing yet</span></p>
</div>
<div class="example" data-desc="Preloading dates" id="defaultdate">
<h3>Preload date and time</h3>
<p>
You may load the calendar with a predefined value, ranging from simple dates, such as "2016-04-10" to full-fledged datetime strings. To keep the dates in UTC/GMT, see the <a href="#utc">UTC option</a>.
</p>
<pre class='prettyprint lang-html'>
<input type=text class=flatpickr data-enable-time=true value="Sun, 24 Jul 2016 05:16:47 GMT">
</pre>
<p>
<input type=text class=flatpickr data-enable-time=true value="Sun, 24 Jul 2016 05:16:47 GMT">
</p>
<br>
<pre class='prettyprint lang-html'>
<input class=flatpickr data-default-date="2016-12-27T16:16:22.585Z" data-enable-time=true>
</pre>
<p>
<input class=flatpickr data-default-date="2016-12-27T16:16:22.585Z" data-enable-time=true>
</p>
</div>
<div class="example" id="strap">
<h3>Custom elements and input groups</h3>
<p>flatpickr can parse an input group of textboxes and buttons, common in <strong>Bootstrap</strong> and other frameworks.</p>
<p>This permits additional markup, as well as custom elements to trigger the state of the calendar. </p>
<p>Mark your input element with
<code>data-input</code> (mandatory), and any additional buttons with
<code>data-toggle</code>,
<code>data-open</code>,
<code>data-close</code>, or
<code>data-clear</code>.</p>
<pre class='prettyprint lang-html'>
<p class="flatpickr" data-wrap="true" data-click-opens="false">
<input placeholder="Pick date" data-input>
<a class="input-btn" data-toggle><i class="icon-calendar"></i></a>
<a class="input-btn" data-clear><i class="icon-close"></i></a>
</p>
</pre>
<p class="flatpickr input-group" data-wrap=true data-click-opens="false">
<input data-input placeholder="Pick date">
<a class="input-btn" data-toggle><i class="icon-calendar"></i></a>
<a class="input-btn" data-clear><i class="icon-close"></i></a>
<div style="clear:both;"></div>
</p>
</div>
<div class="example" data-desc="Disabling dates" id="disable">
<h3>Disabling dates</h3>
<p>Disable a date interval, or a specific date.</p>
<pre class='prettyprint lang-js'>
document.getElementById("#disableRange").flatpickr({
disable: [
{
from: "2016-08-16",
to: "2016-08-19"
},
"2016-08-24",
new Date().fp_incr(30) // 30 days from now
]
});
</pre>
<p>
<input id="disableRange" placeholder="Select date">
</p>
<hr>
<p>Or pass in a custom function and disable dates using any logic you want.</p>
<pre class='prettyprint lang-js'>
document.getElementById("#disableOddDays").flatpickr({
disable: [
function(date){ // disable odd days
return date.getDate()%2 > 0;
}
]
});
</pre>
<p>
<input id="disableOddDays" placeholder="Select date">
</p>
<hr>
<p>Disable <strong>all</strong> dates except the ones you need, by passing in date strings, Date objects, or functions.</p>
<pre class='prettyprint lang-js'>
document.getElementById("#enableNextSeven").flatpickr({
enable: [
{
from: "today",
to: new Date().fp_incr(7) // 7 days from now
}
]
});
</pre>
<p>
<input id="enableNextSeven" placeholder="Select date">
</p>
<hr>
<p>Use custom logic to enable the dates you need. For instance, enable business days of 2016:</p>
<pre class='prettyprint lang-js'>
document.getElementById("#enableCustom").flatpickr({
enable: [
function(dateObj){
return dateObj.getDay() %6 !== 0 && dateObj.getFullYear() === 2016;
}
]
});
</pre>
<p>
<input id="enableCustom" placeholder="Select date">
</p>
</div>
<div class="example" data-desc="Allowing manual input" id="manual_input">
<h3>Allowing manual input</h3>
<p>
You may let your users input dates themselves simply by toggling the <code>allowInput</code> option
</p>
<pre class='prettyprint lang-html'>
<input type=text class=flatpickr data-enable-time=true data-allow-input=true">
</pre>
<p>
<input type=text class=flatpickr data-enable-time=true data-allow-input=true placeholder="Select date">
</p>
</div>
<div class="example" data-desc="Timezones & UTC" id="utc">
<h3>UTC mode</h3>
<p>
By default, JavaScript's Date converts all dates to a local time. However, locale-agnostic databases often store dates in UTC. flatpickr can convert any given dates to UTC and select a datetime in UTC with a simple switch. Here are the previous examples with UTC mode enabled.
</p>
<pre class='prettyprint lang-html'>
<input class=flatpickr data-utc=true data-default-date="1994-11-05 09:15:30 GMT" data-enable-time=true>
</pre>
<p>
<input class=flatpickr data-utc=true data-default-date="1994-11-05 09:15:30 GMT" data-enable-time=true>
</p>
<br>
<pre class='prettyprint lang-html'>
<input class=flatpickr data-default-date="2016-12-27T16:16:22.585Z" data-utc=true data-enable-time=true>
</pre>
<p>
<input class=flatpickr data-default-date="2016-12-27T16:16:22.585Z" data-utc=true data-enable-time=true>
</p>
</div>
<div class="example" data-desc="Events API" id="eventAPI">
<h3>Event API</h3>
<pre class='prettyprint lang-js'>
document.getElementById("events-api-example").flatpickr({
minDate: "today",
enableTime: true,
onChange: function(dateObj, dateStr, instance) {
...
},
onOpen: function(dateObj, dateStr, instance){
...
},
onClose: function(dateObj, dateStr, instance){
...
}
});
</pre>
<p id=events style="height: 80px; overflow-y: auto"></p>
<p>
<input id="events-api-example" placeholder="Select date">
</p>
<hr>
</div>
<div class=example id=checkinnout data-desc="Example: check in/out date">
<h3>Example: check in and check out</h3>
<pre class='prettyprint lang-js'>
var check_in = document.getElementById("check_in_date").flatpickr({
altInput: true,
altFormat: "\\C\\h\\e\\c\\k \\i\\n\\: l, F j Y",
minDate: new Date()
});
var check_out = document.getElementById("check_out_date").flatpickr({
altInput: true,
altFormat: "\\C\\h\\e\\c\\k \\o\\u\\t: l, F j Y",
minDate: new Date()
});
check_in.config.onChange = dateObj => check_out.set("minDate", dateObj.fp_incr(1));
check_out.config.onChange = dateObj => check_in.set("maxDate", dateObj.fp_incr(-1));
</pre>
<p>
<input id="check_in_date" placeholder="Check-In Date">
</p>
<p>
<input id="check_out_date" placeholder="Check Out Date">
</p>
</div>
<div class="example" id=weeknumbers data-desc="Week numbers" >
<h3>Display week numbers</h3>
<pre class='prettyprint lang-html'>
<input class=flatpickr data-week-numbers=true placeholder="Enabled week numbers">
</pre>
<p>
<input class=flatpickr data-week-numbers=true placeholder="Enabled week numbers">
</p>
</div>
<div class="example" id=fiscal-calendar data-desc="Fiscal Calendar" >
<h3>Fiscal Calendar</h3>
<p>
You may override the <code>getWeek()</code> function, used for calculating a week number, for various purposes.
A fiscal year is used for calculating yearly financial statements.
In this example, we will use override the <code>getWeek()</code> function to display the fiscal term instead of the usual week numbers.
</p>
<pre class='prettyprint lang-html'>
<input id="fiscal" placeholder="Fiscal Calendar">
</pre>
<pre class="prettyprint lang-js">
Flatpickr.prototype.getWeek = function(givenDate){
var checkDate = new Date(givenDate.getTime());
checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
var time = checkDate.getTime();
checkDate.setMonth(7);
checkDate.setDate(28);
var week = (Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 2);
if (week < 1) {
week = 52 + week;
}
return 'FW'+week;
}
document.getElementById("fiscal").flatpickr({
weekNumbers: true
});
</pre>
<p>
<input id="fiscal" placeholder="Calendar w/ fiscal periods">
</p>
</div>
<div class="example" id=inline-calendar data-desc="Inline calendar" >
<h3>Inline or embedded calendar</h3>
<pre class='prettyprint lang-html'>
<input class=flatpickr data-inline=true placeholder="Pick a date below">
</pre>
<p>
<input class=flatpickr type=text data-inline=true placeholder="Pick a date below">
</p>
</div>
<div class="example" data-desc="Customizing default options" id="prototype">
<h3>Customizing default options</h3>
<pre class='prettyprint lang-js'>
// use your own arrow icons
Flatpickr.defaultConfig.prevArrow = "<i class='icon i-angle-left'></i>";
Flatpickr.defaultConfig.nextArrow = "<i class='icon i-angle-right'></i>";
// change the first day of the week to Monday
Flatpickr.l10n.firstDayOfWeek = 1;
// then initialize your calendars
....
</pre>
</div>
<div class="example" id=options>
<h3 data-desc="Options">Options</h3>
<p>
<strong>Protip: </strong> <u>all</u> of the string/boolean config options can also be supplied using data attributes, e.g. data-min-date, data-default-date, data-date-format etc.
</p>
<table class=table>
<thead>
<tr>
<th>Config Option</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>altFormat</td>
<td>string</td>
<td>"F j, Y"</td>
<td>Exactly the same as date format, but for the altInput field</td>
</tr>
<tr>
<td>altInput</td>
<td>Boolean</td>
<td>false</td>
<td>Show the user a readable date (as per altFormat), but return something totally different to the server. </td>
</tr>
<tr>
<td>altInputClass</td>
<td>String</td>
<td>""</td>
<td>This class will be added to the input element created by the altInput option. Helpful if input elements are styled using classes. Bootstrap users will want to specify <code>form-control</code> here.</td>
</tr>
<tr>
<td>allowInput</td>
<td>boolean</td>
<td>false</td>
<td>Allows the user to enter a date directly input the input field. By default, direct entry is disabled.</td>
</tr>
<tr>
<td>clickOpens</td>
<td>boolean</td>
<td>true</td>
<td>Clicking on the input opens the date (time) picker. Disable this if you wish to open the calendar manually with <code>.open()</code></td>
</tr>
<tr>
<td>dateFormat</td>
<td>string</td>
<td>"Y-m-d"</td>
<td>A string of characters which are used to define how the date will be displayed in the input box. The supported characters are defined in the table below.</td>
</tr>
<tr>
<td>defaultDate</td>
<td>String/Date Object</td>
<td>null</td>
<td>Set the initial selected date. Same as preloading a date string into an input's value attribute, but can also handle a Date object. </td>
</tr>
<tr>
<td>disable</td>
<td>array</td>
<td>[]</td>
<td>Dates to disable, using intervals</td>
</tr>
<tr>
<td>enableTime</td>
<td>boolean</td>
<td>false</td>
<td>Enables time picker </td>
</tr>
<tr>
<td>enableSeconds</td>
<td>boolean</td>
<td>false</td>
<td>Enables seconds in the time picker.</td>
</tr>
<tr>
<td>noCalendar</td>
<td>boolean</td>
<td>false</td>
<td>Hides the calendar. For use along with enableTime.</td>
</tr>
<tr>
<td>hourIncrement</td>
<td>integer</td>
<td>1</td>
<td>Adjusts the step for the hour input (incl. scrolling) </td>
</tr>
<tr>
<td>minuteIncrement</td>
<td>integer</td>
<td>5</td>
<td>Adjusts the step for the minute input (incl. scrolling) </td>
</tr>
<tr>
<td>inline</td>
<td>boolean</td>
<td>false</td>
<td>Displays the calendar inline. See <a href="https://chmln.github.io/flatpickr/#inline-calendar">Inline or embedded calendar</a>.</td>
</tr>
<tr>
<td>static</td>
<td>boolean</td>
<td>false</td>
<td>Position the calendar inside the wrapper and next to the input element. (Leave <code>false</code> unless you know what you're doing.</td>
</tr>
<tr>
<td>wrap</td>
<td>Boolean</td>
<td>false</td>
<td>The wrapping element. See <a href="https://chmln.github.io/flatpickr/#strap">Custom elements and input groups</a>.</td>
</tr>
<tr>
<td>maxDate</td>
<td>String</td>
<td>null</td>
<td>The maximum date that a user can pick to, as a string.
<br>See <a target=_blank href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse">Date.parse()</a></td>
</tr>
<tr>
<td>minDate</td>
<td>String</td>
<td>null</td>
<td>The minimum date that a user can start picking from, as a string.
<br>See <a target=_blank href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse">Date.parse()</a></td>
</tr>
<tr>
<td>onChange</td>
<td>function(dateObject, dateString)</td>
<td>null</td>
<td>A function that gets triggered on every date selection </td>
</tr>
<tr>
<td>onOpen</td>
<td>function(dateObject, dateString)</td>
<td>null</td>
<td>A function that gets triggered on every time the calendar is opened.</td>
</tr>
<tr>
<td>onClose</td>
<td>function(dateObject, dateString)</td>
<td>null</td>
<td>A function that gets triggered on every time the calendar is closed.</td>
</tr>
<tr>
<td>parseDate</td>
<td>function</td>
<td>false</td>
<td>A function that expects a date string and must return a Date object</td>
</tr>
<tr>
<td>shorthandCurrentMonth</td>
<td>boolean</td>
<td>false</td>
<td>Show the month using the shorthand version (ie, Sep instead of September).</td>
</tr>
<tr>
<td>weekNumbers</td>
<td>boolean</td>
<td>false</td>
<td>Enables display of week numbers in calendar.</td>
</tr>
<tr>
<td>time_24hr</td>
<td>boolean</td>
<td>false</td>
<td>Displays time picker in 24 hour mode without AM/PM selection when enabled.</td>
</tr>
<tr>
<td>utc</td>
<td>boolean</td>
<td>false</td>
<td>When true, dates will parsed, formatted, and displayed in UTC. It's recommended that date strings contain the timezone, but not necessary.</td>
</tr>
<tr>
<td>prevArrow</td>
<td>string</td>
<td><code><</code></td>
<td>Code for the previous icon.</td>
</tr>
<tr>
<td>nextArrow</td>
<td>string</td>
<td><code>></code></td>
<td>Code for the next icon.</td>
</tr>
</tbody>
</table>
</div>
<div class="example" id=dateformat>
<h3>Date Format Characters</h3>
<input class="big" id="dateFormatComposer" placeholder="Enter symbols" type="text">
<span> → <span id="dateFormatOutput"></span></span>
<table class=table>
<thead>
<tr>
<th>Character</th>
<th>Description</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr>
<td>d</td>
<td>Day of the month, 2 digits with leading zeros</td>
<td>01 to 31</td>
</tr>
<tr>
<td>D</td>
<td>A textual representation of a day</td>
<td>Mon through Sun</td>
</tr>
<tr>
<td>l (lowercase 'L')</td>
<td>A full textual representation of the day of the week</td>
<td>Sunday through Saturday</td>
</tr>
<tr>
<td>j</td>
<td>Day of the month without leading zeros</td>
<td>1 to 31</td>
</tr>
<tr>
<td>J</td>
<td>Day of the month without leading zeros and ordinal suffix</td>
<td>1st, 2nd, to 31st</td>
</tr>
<tr>
<td>w</td>
<td>Numeric representation of the day of the week</td>
<td>0 (for Sunday) through 6 (for Saturday)</td>
</tr>
<tr>
<td>F</td>
<td>A full textual representation of a month</td>
<td>January through December</td>
</tr>
<tr>
<td>m</td>
<td>Numeric representation of a month, with leading zero</td>
<td>01 through 12</td>
</tr>
<tr>
<td>n</td>
<td>Numeric representation of a month, without leading zeros</td>
<td>1 through 12</td>
</tr>
<tr>
<td>M</td>
<td>A short textual representation of a month</td>
<td>Jan through Dec</td>
</tr>
<tr>
<td>U</td>
<td>The number of seconds since the Unix Epoch</td>
<td>1413704993</td>
</tr>
<tr>
<td>y</td>
<td>A two digit representation of a year</td>
<td>99 or 03</td>
</tr>
<tr>
<td>Y</td>
<td>A full numeric representation of a year, 4 digits</td>
<td>1999 or 2003</td>
</tr>
</tbody>
</table>
</div>
<div class="example" id=timeformat>
<h3>Time Format Characters</h3>
<table class=table>
<thead>
<tr>
<th>Character</th>
<th>Description</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr>
<td>H</td>
<td>Hours (24 hours)</td>
<td>00 to 23</td>
</tr>
<tr>
<td>h</td>
<td>Hours</td>
<td>1 to 12</td>
</tr>
<tr>
<td>i</td>