Table 4-3 lists the various formatting
options supported by the format methods of the Date extension.
Table 4-3. List of the Supported Date Formats
Format Description
d Short date pattern (e.g., 05/10/07)
D Long date pattern (e.g., Thursday, 10 May 2007)
t Short time pattern (e.g., 18:05)
CHAPTER 4 ?– ASP.NET AJAX CLIENT LIBRARIES 58
T Long time pattern (e.g., 18:05:12)
F Full date pattern (e.g., Thursday, 10 May 2007 18:05:12)
M Month and day pattern (e.g., May 10)
s Sortable date and time pattern (e.g., 2007-05-10T18:05:12)
Y Year and month pattern (e.g., 2007 May)
For instance, to display the present date, you can just instantiate a new Date object, and
using the format method, pass in the intended format provider (as listed in Table 4-3).
function displayDate() {
var today = new Date();
alert (today.format('D'));
}
The formatted date as the result of the preceding script is shown in Figure 4-2.
Figure 4-2. Displaying the current date in long format
Error Extensions
JavaScript has an Error object and is often used in conjunction with try/catch blocks.
Pages:
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