Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 621 lines (592 sloc) 28.165 kb
58240a9 Added ability to specify multiple cultures at once. Added readme. Upd…
InfinitiesLoop authored
1 <h1>Introduction</h1>
2 <p>
3 This jQuery plugin enables complex culture-aware number and date parsing and formatting, including the raw culture information for hunderds of different languages and countries, as well as an extensible system for localization.
4 </p>
5 <ul>
6 <li><a href="#why">Why Globalization</a></li>
7 <li><a href="#what">What is a Culture?</a></li>
8 <li><a href="#cultures">jQuery.cultures</a></li>
9 <li><a href="#culture">jQuery.culture</a></li>
10 <li><a href="#prefer">jQuery.preferCulture</a></li>
11 <li><a href="#find">jQuery.findClosestCulture</a></li>
12 <li><a href="#format">jQuery.format</a></li>
13 <li><a href="#parseInt">jQuery.parseInt</a></li>
14 <li><a href="#parseFloat">jQuery.parseFloat</a></li>
15 <li><a href="#parseDate">jQuery.parseDate</a></li>
16 <li><a href="#localize">jQuery.localize</a></li>
17 <li><a href="#extend">Utilizing and Extending Cultures</a></li>
18 <li><a href="#defining">Defining Culture Information</a></li>
19 <li><a href="#numbers">Number Formatting</a></li>
20 <li><a href="#dates">Date Formatting</a></li>
21 </ul>
22
23 <h2 id="why">Why Globalization?</h2>
24 <p>
25 Each language, and the countries that speak that language, have different expectations when it comes to how numbers (including currency and percentages) and dates should appear. Obviously, each language has different names for the days of the week and the months of the year. But they also have different expectations to the structure of dates, such what order the day, month and year are in. In number formatting, not only does the character used to deliniate number groupings and the decimal portion, but the placement of those characters differ.
26 </p>
27 <p>
28 A user using an application should be able to read and write dates and numbers in the format they are occustomed to. This plugin makes this possible, providing an API to convert user-entered numbers and dates -- in their own format -- into real numbers and dates, and conversely, to format numbers and dates into that format.
29 </p>
30
31 <h2 id="what">What is a Culture?</h2>
32 <p>
33 jQuery.glob.js defines roughly 350 cultures. Part of the reason for this large number, besides there being a lot of cultures of the world, is because for some languages, expectations differ amoung the countries that speak it. English, for example, is an official language in dozens of countries. Despite the language being English, the expected date formatting still greatly differs between them.
34 </p>
35 <p>
36 So, it seems it is not useful to define cultures by their language alone. Nor is it useful to define a culture by it's country alone, as many countries have many official languages, spoken by sizable populations. Therefore, cultures are defined as a combination of the language and the country speaking it. Each culture is given a unique code that is a combination of an ISO 639 two-letter lowercase culture code for the language, and a two-letter uppercase code for the country or region. For example, "en-US" is the culture code for English, in the United States.
37 </p>
38 <p>
39 Yet, it is perhaps unreasonable to expect application developers to cater to every possible language/country combination perfectly. It is important then to define so-called "neutral" cultures based on each language. This culture defines the most likely accepted set of rules by anyone speaking that language, whatever the country. Neutral cultures are defined only by their language code. For example, "es" is the neutral culture for Spanish.
40 </p>
41
42 <h2 id="cultures">jQuery.cultures</h2>
43 <p>
44 A mapping of culture code to that culture. For example, jQuery.cultures.fr is an object representing the complete culture definition for the neutral French culture. Note that jQuery.glob.js alone only includes an English culture. To get additional cultures, you must seperately reference one or more of the culture scripts that come with it. See below on what fields are defined in each culture.
45 </p>
46
47 <h2 id="culture">jQuery.culture</h2>
48 <p>
49 This is set to the culture currently being used. This serves as the default culture if no culture is specified on the various parsing and formatting functions. For example, to change the current culture, set it to one of the available cultures:
50 <pre>
51 jQuery.culture = jQuery.cultures["FR-fr"];
52 </pre>
53 </p>
54
55 <h2 id="prefer">jQuery.preferCulture</h2>
56 <p>
57 An application that supports globalization and/or localization will need to have a way to determine the user's preference. Attempting to automatically determine the appropriate culture is useful, but it is good practice to always offer the user a choice, by whatever means.
58 </p>
59 <p>
60 Whatever your mechanism, it is likely you would have to correlate the user's preferences with the list of cultures the app has specifically decided to support. This API allows you to tell jQuery.glob.js what cultures the user prefers, and select the best match given the culture scripts you have included.
61 </p>
62 <p>If you pass an array, the first culture for which there is a match (that culture's script has been referenced) will be used. If none match, the search restarts using the corresponding neutral cultures. For example, if the application has included only the neutral "fr" culture, any of these would select it:
63 <pre>
64 &lt;script src="jQuery.glob.fr.js" type="text/javascript">&lt;/script>
65 ...
66 jQuery.preferCulture("fr");
67 alert(jQuery.culture.name) // 'fr'
68
69 jQuery.preferCulture("fr-FR");
70 alert(jQuery.culture.name) // 'fr'
71
72 jQuery.preferCulture(["es-MX", "fr-FR"]);
73 alert(jQuery.culture.name) // 'fr'
74 </pre>
75
76 In any case, if no match is found, the invariant culture is selected.
77 </p>
78
79 <h2 id="find">jQuery.findClosestCulture</h2>
80 <p>
81 Just like preferCulture, but it returns the matching culture, if any, rather than setting jQuery.culture to it.
82 </p>
83
84 <h2 id="format">jQuery.format(value, format, culture)</h2>
85 <p>
86 Formats a date or number according to the given format string and the given culture (or the current culture if not specified). See the section below on number and date formatting tokens for details on the available formats.
87 <pre>
88 // assuming a culture with number grouping of 3 digits, using "," separator and "." decimal symbol.
89 jQuery.format(1234.567, "n"); // "1,234.57"
90 jQuery.format(1234.567, "n1"); // "1,234.6"
91 jQuery.format(1234.567, "n0"); // "1,235"
92
93 // assuming a culture with "/" as the date separator symbol
94 jQuery.format(new Date(1955,10,5), "yyyy/MM/dd"); // 1955/11/05
95 jQuery.format(new Date(1955,10,5), "dddd MMMM d, yyyy"); // Saturday November 5, 1955
96 </pre>
97 </p>
98
99 <h2 id="parseInt">jQuery.parseInt(value, radix, culture)</h2>
100 <p>
101 Parses a string representing a whole number in the given the radix (10 by default), taking into account any formatting rules followed by the given culture (or the current culture, if not specified).
102 <pre>
103 // assuming a culture where "," is the group separator and "." is the decimal separator
104 jQuery.parseInt("1,234.56"); // 1234
105 // assuming a culture where "." is the group separator and "," is the decimal separator
106 jQuery.parseInt("1.234,56"); // 1234
107 </pre>
108 </p>
109
110 <h2 id="parseFloat">jQuery.parseFloat(value, radix, culture)</h2>
111 <p>
112 Parses a string representing a floating point number in the given the radix (10 by default), taking into account any formatting rules followed by the given culture (or the current culture, if not specified).
113 </p>
114
115 <h2>jQuery.parseDate(value, formats, culture)</h2>
116 <p>
117 Parses a string representing a date into a JavaScript Date object, taking into account the given possible formats (or the given culture's set of default formats if not given). As before, the current culture is used if one is not specified.
118 <pre>
119 jQuery.culture = jQuery.culture.en;
120 jQuery.parseDate("1/2/2003"); // Thu Jan 02 2003
121 jQuery.culture = jQuery.culture.fr;
122 jQuery.parseDate("1/2/2003"); // Sat Feb 01 2003
123 </pre>
124 </p>
125
126 <h2 id="localize">jQuery.localize(key, culture, value)</h2>
127 <p>
128 Gets or sets a localized value. This function allows you to extend the information available to a particular culture, and to easily retrieve it without worrying about finding the most appropriate culture. For example, to define the word "translate" in French:
129 <pre>
130 jQuery.localize("translate", "fr", "traduire");
131 </pre>
132 The value may be any value you wish -- a string, number, object, etc. You can then define a grouping of localized values common to a feature, plugin, or application.
133 <pre>
134 jQuery.localize("myplugin", "fr", {
135 foo: "foo",
136 bar: "bar"
137 });
138
139 var obj = jQuery.localize("myplugin", "fr");
140 alert(obj.foo); // "foo"
141 </pre>
142 Note that localize() will find the closest match available per the same semantics as the jQuery.findClosestCulture function. If there is no match, the translation given is for the neutral culture, if any.
143 <pre>
144 jQuery.localize("myplugin", "", {
145 foo: "foo (invariant)",
146 bar: "bar (invariant)"
147 });
148 jQuery.localize("myplugin", "fr", {
149 foo: "foo",
150 bar: "bar"
151 });
152
153 jQuery.culture = jQuery.cultures["fr"];
154 alert(jQuery.localize("myplugin").foo); // foo
155
156 jQuery.culture = jQuery.cultures["fr-FR"];
157 alert(jQuery.localize("myplugin").foo); // foo
158
159 jQuery.culture = jQuery.cultures["es-MX"];
160 jQuery.culture = jQuery.cultures["fr-FR"];
161 alert(jQuery.localize("myplugin").foo); // foo (invariant)
162 </pre>
163 Also note that localize() does not require loading the culture information script. You may use localize() for localization purposes without utilizing the parsing and formatting functions which depend on the cultures. If you do use both, it does not matter what order you include them in, either may be first -- the jQuery.glob.&lt;code&gt;.js script, or your own script which uses localize().
164 </p>
165
166 <h2 id="extend">Utilizing and Extending Cultures</h2>
167 <p>
168 The culture information included with each culture is mostly necessary for the parsing and formatting methods, but not all of it. For example, the the Native and English names for each culture is given, as well as a boolean indicating whether the language is right-to-left. This may be useful information for your own purposes. You may also add to the culture information directly if so desired. It is important to do so in a way that handles the fact that the culture info may not be provided, may not be provided yet, or may already be provided. Using jQuery's extend() method, it is possible to define a culture in a way that both defines if it does not exist and adds to it if it does exist.
169 </p>
170 <p>
171 As an example, in the U.S., the word "billion" means the number 1,000,000,000 (9 zeros). But in other countries, that number is "1000 million" or a "milliard", and a billion is 1,000,000,000,000 (12 zeros). If you needed to provide functionality to your app or custom plugin that needed to know how many zeros are in a 'billion', you could extend the culture information as follows:
172 <pre>
173 // define culture information without overwriting any existing values
174 jQuery.cultures.fr = jQuery.extend(true, {
175 numberFormat: {
176 billionZeros: 12
177 }
178 }, jQuery.cultures.fr);
179 </pre>
180 Using this mechanism, the 'fr' culture will be created if it does not exist. And if it does, the given values will be added to it, taking care not to overwrite anything that is already defined (if you'd prefer to overwrite, you'd switch the last two arguments). When the jQuery.glob.fr.js script is eventually included, it too uses this technique, ensuring addition to the already-defined culture information.
181 </p>
182
183 <h2 id="defining">Defining Culture Information</h2>
184 <p>
185 Each culture is defined in its own script with the naming scheme jQuery.glob.&lt;code&gt;.js (along with its minified version, jQuery.glob.&lt;code&gt;.min.js). You may include any number of these scripts, making them available in the jQuery.cultures mapping. Including one of these scripts does NOT automatically make it the default culture selected with jQuery.culture.
186 </p>
187 <p>
188 The neutral culture that comes with jQuery.glob.js is heavily commented, describing the purpose of each of the fields defined by a culture. Note that every culture includes all of these fields, even if they are the same as the netural culture. However, the script uses jQuery's $.extend to copy from the neutral culture, so looking at the raw scripts will only show you what is different in that culture from the neutral culture. The neutral culture is listed here along with the comments:
189 <pre>
190 jQuery.cultures.invariant = {
191 // A unique name for the culture in the form &lt;language code&gt;-&lt;country/region code&lt;
192 name: "invariant",
193 // the name of the culture in the english language
194 englishName: "Invariant",
195 // the name of the culture in its own language
196 nativeName: "Invariant",
197 // whether the culture uses right-to-left text
198 isRTL: false,
199 // 'language' is used for so-called "specific" cultures.
200 // For example, the culture "es-CL" means "Spanish, in Chili".
201 // It represents the Spanish-speaking culture as it is in Chili,
202 // which might have different formatting rules or even translations
203 // than Spanish in Spain. A "neutral" culture is one that is not
204 // specific to a region. For example, the culture "es" is the generic
205 // Spanish culture, which may be a more generalized version of the language
206 // that may or may not be what a specific culture expects.
207 // For a specific culture like "es-CL", the 'language' field refers to the
208 // neutral, generic culture information for the language it is using.
209 // This is not always a simple matter of the string before the dash.
210 // For example, the "zh-Hans" culture is netural (Simplified Chinese).
211 // And the 'zh-SG' culture is Simplified Chinese in Singapore, whose lanugage
212 // field is "zh-CHS", not "zh".
213 // This field should be used to navigate from a specific culture to it's
214 // more general, neutral culture. If a culture is already as general as it
215 // can get, the language may refer to itself.
216 language: "",
217 // numberFormat defines general number formatting rules, like the digits in
218 // each grouping, the group separator, and how negative numbers are displayed.
219 numberFormat: {
220 // [negativePattern]
221 // Note, numberFormat.pattern has no 'positivePattern' unlike percent and currency,
222 // but is still defined as an array for consistency with them.
223 // negativePattern: one of "(n)|-n|- n|n-|n -"
224 pattern: ["-n"],
225 // number of decimal places normally shown
226 decimals: 2,
227 // string that separates number groups, as in 1,000,000
228 ',': ",",
229 // string that separates a number from the fractional portion, as in 1.99
230 '.': ".",
231 // array of numbers indicating the size of each number group.
232 groupSizes: [3],
233 // symbol used for positive numbers
234 '+': "+",
235 // symbol used for negative numbers
236 '-': "-",
237 percent: {
238 // [negativePattern, positivePattern]
239 // negativePattern: one of "-n %|-n%|-%n|%-n|%n-|n-%|n%-|-% n|n %-|% n-|% -n|n- %"
240 // positivePattern: one of "n %|n%|%n|% n"
241 pattern: ["-n %","n %"],
242 // number of decimal places normally shown
243 decimals: 2,
244 // array of numbers indicating the size of each number group.
245 groupSizes: [3],
246 // string that separates number groups, as in 1,000,000
247 ',': ",",
248 // string that separates a number from the fractional portion, as in 1.99
249 '.': ".",
250 // symbol used to represent a percentage
251 symbol: "%"
252 },
253 currency: {
254 // [negativePattern, positivePattern]
255 // negativePattern: one of "($n)|-$n|$-n|$n-|(n$)|-n$|n-$|n$-|-n $|-$ n|n $-|$ n-|$ -n|n- $|($ n)|(n $)"
256 // positivePattern: one of "$n|n$|$ n|n $"
257 pattern: ["($n)","$n"],
258 // number of decimal places normally shown
259 decimals: 2,
260 // array of numbers indicating the size of each number group.
261 groupSizes: [3],
262 // string that separates number groups, as in 1,000,000
263 ',': ",",
264 // string that separates a number from the fractional portion, as in 1.99
265 '.': ".",
266 // symbol used to represent currency
267 symbol: "¤"
268 }
269 },
270 // calendars defines all the possible calendars used by this culture.
271 // There should be at least one defined with name 'standard', and is the default
272 // calendar used by the culture.
273 // A calendar contains information about how dates are formatted, information about
274 // the calendar's eras, a standard set of the date formats,
275 // translations for day and month names, and if the calendar is not based on the Gregorian
276 // calendar, conversion functions to and from the Gregorian calendar.
277 calendars: {
278 standard: {
279 // name that identifies the type of calendar this is
280 name: "Gregorian_USEnglish",
281 // separator of parts of a date (e.g. '/' in 11/05/1955)
282 '/': "/",
283 // separator of parts of a time (e.g. ':' in 05:44 PM)
284 ':': ":",
285 // the first day of the week (0 = Sunday, 1 = Monday, etc)
286 firstDay: 0,
287 days: [
288 // full day names
289 ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],
290 // abbreviated day names
291 ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],
292 // shortest day names
293 ["Su","Mo","Tu","We","Th","Fr","Sa"]
294 ],
295 months: [
296 // full month names (13 months for lunar calendars -- 13th month should be "" if not lunar)
297 ["January","February","March","April","May","June","July","August","September","October","November","December",""],
298 // abbreviated month names
299 ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",""]
300 ],
301 // AM and PM designators in one of these forms:
302 // The usual view, and the upper and lower case versions
303 // [standard,lowercase,uppercase]
304 // The culture does not use AM or PM (likely all standard date formats use 24 hour time)
305 // null
306 AM: ["AM", "am", "AM"],
307 PM: ["PM", "pm", "PM"],
308 eras: [
309 // eras in reverse chronological order.
310 // name: the name of the era in this culture (e.g. A.D., C.E.)
311 // start: when the era starts in ticks, null if it is the earliest supported era.
312 // offset: offset in years from gregorian calendar
313 {"name":"A.D.","start":null,"offset":0}
314 ],
315 // when a two digit year is given, it will never be parsed as a four digit
316 // year great than this year (in the appropriate era for the culture)
317 twoDigitYearMax: 2029,
318 // set of predefined date and time patterns used by the culture
319 // these represent the format someone in this culture would expect
320 // to see given the portions of the date that are shown.
321 patterns: {
322 // short date pattern
323 d: "MM/dd/yyyy",
324 // long date pattern
325 D: "dddd, dd MMMM yyyy",
326 // short time pattern
327 t: "HH:mm",
328 // long time pattern
329 T: "HH:mm:ss",
330 // long date, short time pattern
331 f: "dddd, dd MMMM yyyy HH:mm",
332 // long date, long time pattern
333 F: "dddd, dd MMMM yyyy HH:mm:ss",
334 // month/day pattern
335 M: "MMMM dd",
336 // month/year pattern
337 Y: "yyyy MMMM",
338 // S is a sortable format that does not vary by culture
339 S: "yyyy\u0027-\u0027MM\u0027-\u0027dd\u0027T\u0027HH\u0027:\u0027mm\u0027:\u0027ss"
340 }
341 // optional fields for each calendar:
342 /*
343 monthsGenitive:
344 Same as months but used when the day preceeds the month.
345 Omit if the culture has no genitive distinction in month names.
346 For an explaination of genitive months, see http://blogs.msdn.com/michkap/archive/2004/12/25/332259.aspx
347 convert:
348 Allows for the support of non-gregorian based calendars. This convert object is used to
349 to convert a date to and from a gregorian calendar date to handle parsing and formatting.
350 The two functions:
351 fromGregorian(date)
352 Given the date as a parameter, return an array with parts [year, month, day]
353 corresponding to the non-gregorian based year, month, and day for the calendar.
354 toGregorian(year, month, day)
355 Given the non-gregorian year, month, and day, return a new Date() object
356 set to the corresponding date in the gregorian calendar.
357 */
358 }
359 }
360 }
361 </pre>
362 </p>
363 <p>
364 Each culture can have several possible calendars. The calendar named "standard" is the default calendar used by that culture. You may change the calendar in use by setting the 'calendar' field. Take a look at the calendars defined by each culture by looking at the script or enumerating its calendars collection.
365 <pre>
366 // switch to a non-standard calendar
367 $.culture.calendar = $.culture.calendars.SomeOtherCalendar;
368 // back to the standard calendar
369 $.culture.calendar = $.culture.calendars.standard;
370 </pre>
371
372 </p>
373
374 <h2 id="numbers">Number Formatting</h2>
375 <p>
376 When formatting a number with format(), the main purpose is to convert the number into a human readable string using the culture's standard grouping and decimal rules. The rules between cultures can vary a lot. For example, in some cultures, the grouping of numbers is done unevenly. In the "te-IN" culture (Telugu in India), groups have 3 digits and then 2 digits. The number 1000000 (one million) is written as "10,00,000". Some cultures do not group numbers at all.
377 </p>
378 <p>
379 There are four main types of number formatting:
380 <ul>
381 <li><strong>n</strong> for number</li>
382 <li><strong>d</strong> for decimal digits</li>
383 <li><strong>p</strong> for percentage</li>
384 <li><strong>c</strong> for currency</li>
385 </ul>
386 Even within the same culture, the formatting rules can vary between these four types of numbers. For example, the expected number of decimal places may differ from the number format to the currency format. Each format token may also be followed by a number. The number determines how many decimals places to display for all the format types except decimal, for which it means the minimum number of digits to display, zero padding it if necessary. Also note that the way negative numbers are represented in each culture can vary, such as what the negative sign is, and whether the negative sign appears before or after the number. This is especially apparent with currency formatting, where many cultures use parentheses instead of a negative sign.
387 <pre>
388 // just for example -- will vary by culture
389 jQuery.format(123.45, "n"); // 123.45
390 jQuery.format(123.45, "n0"); // 123
391 jQuery.format(123.45, "n1"); // 123.5
392
393 jQuery.format(123.45, "d"); // 123
394 jQuery.format(12, "d3"); // 012
395
396 jQuery.format(123.45, "c"); // $123.45
397 jQuery.format(123.45, "c0"); // $123
398 jQuery.format(123.45, "c1"); // $123.5
399 jQuery.format(-123.45, "c"); // ($123.55)
400
401 jQuery.format(0.12345, "p"); // 12.35 %
402 jQuery.format(0.12345, "p0"); // 12 %
403 jQuery.format(0.12345, "p4"); // 12.3450 %
404 </pre>
405 Parsing with parseInt and parseFloat also accepts any of these formats.
406 </p>
407
408 <h2 id="dates">Date Formatting</h2>
409 <p>
410 Date formatting varies wildly by culture, not just in the spelling of month and day names, and the date separator, but by the expected order of the various date components, whether to use a 12 or 24 hour clock, and how months and days are abbreivated. Many cultures even include "genative" month names, which are different from the typical names and are used only in certain cases.
411 </p>
412 <p>
413 Also, each culture has a set of "standard" or "typical" formats. For example, in en-US, when displaying a date in its fullest form, it looks like "Saturday, November 05, 1955". Note the non-abbreivated day and month name, the zero padded date, and four digit year. So, jQuery.glob.js defines a certain set of "standard" formatting strings for dates that are aliases to the specific formats for the culture. See the 2nd table below for the meaning of each token in the en-US examples.
414 <table>
415 <tr>
416 <th>Token</th>
417 <th>Meaning</th>
418 <th>en-US (example)</th>
419 </tr>
420 <tr>
421 <td>f</td>
422 <td>Long Date, Short Time</td>
423 <td>dddd, MMMM dd, yyyy h:mm tt</td>
424 </tr>
425 <tr>
426 <td>F</td>
427 <td>Long Date, Long Time</td>
428 <td>dddd, MMMM dd, yyyy h:mm:ss tt</td>
429 </tr>
430 <tr>
431 <td>t</td>
432 <td>Short Time</td>
433 <td>h:mm tt</td>
434 </tr>
435 <tr>
436 <td>T</td>
437 <td>Long Time</td>
438 <td>h:mm:ss tt</td>
439 </tr>
440 <tr>
441 <td>d</td>
442 <td>Short Date</td>
443 <td>M/d/yyyy</td>
444 </tr>
445 <tr>
446 <td>D</td>
447 <td>Long Date</td>
448 <td>dddd, MMMM dd, yyyy</td>
449 </tr>
450 <tr>
451 <td>Y</td>
452 <td>Month/Year</td>
453 <td>MMMM, yyyy</td>
454 </tr>
455 <tr>
456 <td>M</td>
457 <td>Month/Day</td>
458 <td>yyyy MMMM</td>
459 </tr>
460 </table>
461 </p>
462 <p>
463 In addition to these standard formats, there is the 'S' format. This is a sortable format that is always the same for every culture: <strong>yyyy'-'MM'-'dd'T'HH':'mm':'ss</strong>.
464 </p>
465 <p>
466 When more specific control is needed over the formatting, you may use any format you wish by specifing the the following custom tokens:
467 <table>
468 <tr>
469 <th>Token</th>
470 <th>Meaning</th>
471 <th>Example</th>
472 </tr>
473 <tr>
474 <td>d</td>
475 <td>Day of month (no leading zero)</td>
476 <td>5</td>
477 </tr>
478 <tr>
479 <td>dd</td>
480 <td>Day of month (leading zero)</td>
481 <td>05</td>
482 </tr>
483 <tr>
484 <td>ddd</td>
485 <td>Day name (abbreviated)</td>
486 <td>Sat</td>
487 </tr>
488 <tr>
489 <td>dddd</td>
490 <td>Day name (full)</td>
491 <td>Saturday</td>
492 </tr>
493 <tr>
494 <td>M</td>
495 <td>Month of year (no leading zero)</td>
496 <td>9</td>
497 </tr>
498 <tr>
499 <td>MM</td>
500 <td>Month of year (leading zero)</td>
501 <td>09</td>
502 </tr>
503 <tr>
504 <td>MMM</td>
505 <td>Month name (abbreivated)</td>
506 <td>Sept</td>
507 </tr>
508 <tr>
509 <td>MMMM</td>
510 <td>Month name (full)</td>
511 <td>September</td>
512 </tr>
513 <tr>
514 <td>yy</td>
515 <td>Year (two digits)</td>
516 <td>55</td>
517 </tr>
518 <tr>
519 <td>yyyy</td>
520 <td>Year (four digits)</td>
521 <td>1955</td>
522 </tr>
523 <tr>
524 <td>'literal'</td>
525 <td>Literal Text</td>
526 <td>'Hmmmm'...</td>
527 </tr>
528 <tr>
529 <td>\'</td>
530 <td>Single Quote</td>
531 <td>&nbsp;</td>
532 </tr>
533 <tr>
534 <td>m</td>
535 <td>Minutes (no leading zero)</td>
536 <td>9</td>
537 </tr>
538 <tr>
539 <td>mm</td>
540 <td>Minutes (leading zero)</td>
541 <td>09</td>
542 </tr>
543 <tr>
544 <td>h</td>
545 <td>Hours (leading zero)</td>
546 <td>6</td>
547 </tr>
548 <tr>
549 <td>hh</td>
550 <td>Hours (leading zero)</td>
551 <td>06</td>
552 </tr>
553 <tr>
554 <td>H</td>
555 <td>Hours (24 hour time, no leading zero)</td>
556 <td>5 (5am) 15 (3pm)</td>
557 </tr>
558 <tr>
559 <td>HH</td>
560 <td>Hours (24 hour time, leading zero)</td>
561 <td>05 (5am) 15 (3pm)</td>
562 </tr>
563 <tr>
564 <td>s</td>
565 <td>Seconds (no leading zero)</td>
566 <td>9</td>
567 </tr>
568 <tr>
569 <td>ss</td>
570 <td>Seconds (leading zero)</td>
571 <td>09</td>
572 </tr>
573 <tr>
574 <td>f</td>
575 <td>Deciseconds</td>
576 <td>1</td>
577 </tr>
578 <tr>
579 <td>ff</td>
580 <td>Centiseconds</td>
581 <td>11</td>
582 </tr>
583 <tr>
584 <td>fff</td>
585 <td>Milliseconds</td>
586 <td>111</td>
587 </tr>
588 <tr>
589 <td>t</td>
590 <td>AM/PM indicator (first letter)</td>
591 <td>A or P</td>
592 </tr>
593 <tr>
594 <td>tt</td>
595 <td>AM/PM indicator (full)</td>
596 <td>AM or PM</td>
597 </tr>
598 <tr>
599 <td>z</td>
600 <td>Timezone offset (hours only, no leading zero)</td>
601 <td>-8</td>
602 </tr>
603 <tr>
604 <td>zz</td>
605 <td>Timezone offset (hours only, leading zero)</td>
606 <td>-08</td>
607 </tr>
608 <tr>
609 <td>zzz</td>
610 <td>Timezone offset (full hours/minutes)</td>
611 <td>-08:00</td>
612 </tr>
613 <tr>
614 <td>g or gg</td>
615 <td>Era name</td>
616 <td>A.D.</td>
617 </tr>
618 </table>
619 </p>
620
Something went wrong with that request. Please try again.