Debian Codegraph @

docs/example-option-date-format.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>jQuery tablesorter 2.0 - Changing the date format</title>
6
7 <!-- jQuery -->
8 <script src="js/jquery-latest.min.js"></script>
9
10 <!-- Demo stuff -->
11 <link rel="stylesheet" href="css/jq.css">
12 <link href="css/prettify.css" rel="stylesheet">
13 <script src="js/prettify.js"></script>
14 <script src="js/docs.js"></script>
15
16 <!-- Tablesorter: required -->
17 <link rel="stylesheet" href="../css/theme.blue.css">
18 <script src="../js/jquery.tablesorter.js"></script>
19
20 <script id="js">$(function() {
21 // call the tablesorter plugin
22 $("table").tablesorter({
23 theme : 'blue',
24
25 dateFormat : "mmddyyyy", // set the default date format
26
27 // or to change the format for specific columns, add the dateFormat to the headers option:
28 headers: {
29 0: { sorter: "shortDate" } //, dateFormat will parsed as the default above
30 // 1: { sorter: "shortDate", dateFormat: "ddmmyyyy" }, // set day first format; set using class names
31 // 2: { sorter: "shortDate", dateFormat: "yyyymmdd" } // set year first format; set using data attributes (jQuery data)
32 }
33
34 });
35 });</script>
36 </head>
37 <body>
38 <div id="banner">
39 <h1>table<em>sorter</em></h1>
40 <h2>Changing the date format</h2>
41 <h3>Flexible client-side table sorting</h3>
42 <a href="index.html">Back to documentation</a>
43 </div>
44 <div id="main">
45
46 <p class="tip">
47 <em>NOTE!</em>
48 </p>
49 <ul>
50 <li>The dateFormat option was modified in version 2.0.23 (not part of the original plugin).</li>
51 <li>The dateFormat option will ONLY work with the <code>shortDate</code> parser.</li>
52 <li>The date can be separated by any of the following: slash, dash, period, comma, space(s) or tab (/-., ).</li>
53 <li>This date format parser will only work with a four digit year. You can <a href="example-parsers.html">write your own</a> if you need a two digit year parser.</li>
54 <li>In versions 2.3+, date formats can be set by column using any of the following methods (they all do the same thing), in order of priority:
55 <ul>
56 <li>jQuery data <code>data-date-format="mmddyyyy"</code> (see the Javascript block below on how to set it directly; <code>data-dateFormat</code> is equivalent to <code>data-date-format</code>).</li>
57 <li>metadata <code>class="{ dateFormat: "mmddyyyy" }"</code>. This requires the metadata plugin.</li>
58 <li>headers option <code>headers : { 0 : { dateFormat: "mmddyyyy" } }</code>.</li>
59 <li>header class name <code>class="dateFormat-mmddyyyy"</code>.</li>
60 <li>Global (all columns) <code>dateFormat</code> option setting.</li>
61 </ul>
62 </li>
63 </ul>
64
65
66 <h1>Demo</h1>
67 <div id="demo"><table class="tablesorter">
68 <thead>
69 <tr>
70 <th>Date MMDDYYYY</th>
71 <th class="sorter-shortDate dateFormat-ddmmyyyy">Date DDMMYYYY</th>
72 <th data-sorter="shortDate" data-date-format="yyyymmdd">Date YYYYMMDD</th>
73 </tr>
74 </thead>
75 <tbody>
76 <tr>
77 <td>8-7-2011</td>
78 <td>7-8-2011</td>
79 <td>2011-8-7</td>
80 </tr>
81 <tr>
82 <td>11/1/2011 12:34 AM</td>
83 <td>1/11/2011 12:34 AM</td>
84 <td>2011/11/1 12:34 AM</td>
85 </tr>
86 <tr>
87 <td>12/28/2011</td>
88 <td>28/12/2011</td>
89 <td>2011/12/28</td>
90 </tr>
91 <tr>
92 <td>6 30 2011</td>
93 <td>30 6 2011</td>
94 <td>2011 6 30</td>
95 </tr>
96 <tr>
97 <td>11/1/2011 12:35 AM</td>
98 <td>1/11/2011 12:35 AM</td>
99 <td>2011/11/1 12:35 AM</td>
100 </tr>
101 <tr>
102 <td>3.4.2011</td>
103 <td>4.3.2011</td>
104 <td>2011.3.4</td>
105 </tr>
106 <tr>
107 <td>07 01-2011 1:15 PM</td>
108 <td>01 7-2011 1:15 PM</td>
109 <td>2011-7 01 1:15 PM</td>
110 </tr>
111 <tr>
112 <td>04/5,2011</td>
113 <td>5/04,2011</td>
114 <td>2011,04/5</td>
115 </tr>
116 <tr>
117 <td>11/1/2011 12:34 PM</td>
118 <td>1/11/2011 12:34 PM</td>
119 <td>2011/11/1 12:34 PM</td>
120 </tr>
121 <tr>
122 <td>1/21 2011</td>
123 <td>21.1/2011</td>
124 <td>2011/1.21</td>
125 </tr>
126 <tr>
127 <td>5.24-2011</td>
128 <td>24.5-2011</td>
129 <td>2011-5.24</td>
130 </tr>
131 <tr>
132 <td>07/01-2011 12:15 PM</td>
133 <td>01-7/2011 12:15 PM</td>
134 <td>2011/7-01 12:15 PM</td>
135 </tr>
136 <tr>
137 <td>10,14,2011</td>
138 <td>14,10,2011</td>
139 <td>2011,10,14</td>
140 </tr>
141 <tr>
142 <td>09 07 2011</td> <!-- lot of spaces between the numbers -->
143 <td>07 09 2011</td>
144 <td>2011 09 07</td>
145 </tr>
146 <tr>
147 <td>2 27.2011</td>
148 <td>27 2.2011</td>
149 <td>2011 2 27</td>
150 </tr>
151 <tr>
152 <td>8 07 2010</td> <!-- separated by tabs -->
153 <td>07 8 2010</td>
154 <td>2010 8 07</td>
155 </tr>
156 </tbody>
157 </table></div>
158
159 <h1>Javascript</h1>
160 <div id="javascript">
161 <pre class="prettyprint lang-javascript"></pre>
162 </div>
163 <h1>HTML</h1>
164 <div id="html">
165 <pre class="prettyprint lang-html"></pre>
166 </div>
167
168 <div class="next-up">
169 <hr />
170 Next up: <a href="example-parsers.html">Parser, writing your own &rsaquo;&rsaquo;</a>
171 </div>
172
173 </div>
174
175 </body>
176 </html>