1HTML::FormHandler::FielUds:e:rDaCtoen(t3r)ibuted Perl DoHcTuMmLe:n:tFaotrimoHnandler::Field::Date(3)
2
3
4
6 HTML::FormHandler::Field::Date - a date field with formats
7
9 version 0.40068
10
12 This field may be used with the jQuery Datepicker plugin.
13
14 You can specify the format for the date using jQuery formatDate strings
15 or DateTime strftime formats. (Default format is format => '%Y-%m-%d'.)
16
17 d - "%e" - day of month (no leading zero)
18 dd - "%d" - day of month (two digit)
19 o - "%{day_of_year}" - day of the year (no leading zeros)
20 oo - "%j" - day of the year (three digit)
21 D - "%a" - day name short
22 DD - "%A" - day name long
23 m - "%{day_of_month}" - month of year (no leading zero)
24 mm - "%m" - month of year (two digit) "%m"
25 M - "%b" - month name short
26 MM - "%B" - month name long
27 y - "%y" - year (two digit)
28 yy - "%Y" - year (four digit)
29 @ - "%s" - Unix timestamp (ms since 01/01/1970)
30
31 For example:
32
33 has_field 'start_date' => ( type => 'Date', format => "dd/mm/y" );
34
35 or
36
37 has_field 'start_date' => ( type => 'Date', format => "%d/%m/%y" );
38
39 You can also set 'date_end' and 'date_start' attributes for validation
40 of the date range. Use iso_8601 formats for these dates ("yyyy-mm-dd");
41 The dates can be specified either as a string, or as a subref; the
42 subref is evaluated at validation time.
43
44 has_field 'start_date' => ( type => 'Date', date_start => "2009-12-25", date_end => sub { DateTime->now->ymd } );
45
46 Customize error messages 'date_early' and 'date_late':
47
48 has_field 'start_date' => ( type => 'Date,
49 messages => { date_early => 'Pick a later date',
50 date_late => 'Pick an earlier date', } );
51
52 Using with HTML5
53 If the field's form has its 'is_html5' flag active, then the field's
54 rendering behavior changes in two ways:
55
56 • It will render as <input type="date" ... /> instead of type="text".
57
58 • If the field's format is set to anything other than ISO date format
59 (%Y-%m-%d), then attempting to render the field will result in a
60 warning.
61
62 (Note that the default value for the field's format attribute is,
63 in fact, the ISO date format.)
64
66 FormHandler Contributors - see HTML::FormHandler
67
69 This software is copyright (c) 2017 by Gerda Shank.
70
71 This is free software; you can redistribute it and/or modify it under
72 the same terms as the Perl 5 programming language system itself.
73
74
75
76perl v5.34.0 2021-07-22 HTML::FormHandler::Field::Date(3)