You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/date-formatting/index.md
+96-94Lines changed: 96 additions & 94 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,89 +8,91 @@ position: 1
8
8
9
9
# Date Formatting
10
10
11
-
Date formatting converts a `Date` object to a human-readable string using the locale specific settings. The `formatDate` method supports the usage of predefined and custom formats specified as strings, and standard formats specified as objects.
11
+
Date formatting converts a `Date` object to a human-readable string using the locale specific settings.
12
+
13
+
The `formatDate` method supports the usage of predefined and custom formats specified as strings, and standard formats specified as objects.
12
14
13
15
## Types of Date Formats
14
16
15
17
### Predefined
16
18
17
19
***The `d` specifier**—Renders a short date pattern: `"M/d/y"` for en.
@@ -100,35 +102,35 @@ The following specifiers can be used in the custom formats.
100
102
101
103
For the abbreviated name, use one to three letters. For the wide name, use four letters. For the narrow name, use five letters.
102
104
103
-
import { formatDate } from '@telerik/kendo-intl';
105
+
import { formatDate } from '@telerik/kendo-intl';
104
106
105
-
formatDate(new Date(2000, 0, 1), "y G"); // 2000 AD
107
+
formatDate(new Date(2000, 0, 1), "y G"); // 2000 AD
106
108
107
109
***The `"y"` specifier**—Renders the year.
108
110
109
111
To render the full year, use one letter. To render a two-digit year, use two letters. To render a zero-padded year, if necessary, use three or four letters.
110
112
111
-
import { formatDate } from '@telerik/kendo-intl';
113
+
import { formatDate } from '@telerik/kendo-intl';
112
114
113
-
formatDate(new Date(2000, 0, 1), "y"); // 2000
115
+
formatDate(new Date(2000, 0, 1), "y"); // 2000
114
116
115
-
formatDate(new Date(2011, 0, 1), "yy"); // 11
117
+
formatDate(new Date(2011, 0, 1), "yy"); // 11
116
118
117
-
formatDate(new Date(111, 0, 1), "yyyy"); // 0111
119
+
formatDate(new Date(111, 0, 1), "yyyy"); // 0111
118
120
119
121
***The `"Q"` specifier**—Renders a quarter of the year.
120
122
121
123
For the numerical quarter, use one or two letters. For the abbreviation, use three letters. For the wide name, use four letters. For the narrow name, use five letters.
***The `"q"` specifier**—The same as the `"Q"` specifier except that the `"q"` specifier uses the standalone names.
134
136
@@ -138,151 +140,151 @@ The following specifiers can be used in the custom formats.
138
140
139
141
When you use two letters, the month number is rendered as zero-padded.
140
142
141
-
import { formatDate } from '@telerik/kendo-intl';
143
+
import { formatDate } from '@telerik/kendo-intl';
142
144
143
-
formatDate(new Date(2000, 0, 1), "M"); // 1
145
+
formatDate(new Date(2000, 0, 1), "M"); // 1
144
146
145
-
formatDate(new Date(2000, 0, 1), "MM"); // 01
147
+
formatDate(new Date(2000, 0, 1), "MM"); // 01
146
148
147
-
formatDate(new Date(2000, 0, 1), "MMM"); // Jan
149
+
formatDate(new Date(2000, 0, 1), "MMM"); // Jan
148
150
149
-
formatDate(new Date(2000, 0, 1), "MMMM"); // January
151
+
formatDate(new Date(2000, 0, 1), "MMMM"); // January
150
152
151
-
formatDate(new Date(2000, 0, 1), "MMMMM"); // J
153
+
formatDate(new Date(2000, 0, 1), "MMMMM"); // J
152
154
153
155
***The `"L"` specifier**—The same as the `"M"` specifier except that the `"L"` specifier uses the standalone names.
154
156
155
157
***The `"d"` specifier**—Renders the day of the month.
156
158
157
159
To show the minimum number of digits, use `"d"`. To always show two digits, use `"dd"` (zero-padding, if necessary—for example, "08").
158
160
159
-
import { formatDate } from '@telerik/kendo-intl';
161
+
import { formatDate } from '@telerik/kendo-intl';
160
162
161
-
formatDate(new Date(2000, 0, 1), "y d"); // 2000 1
163
+
formatDate(new Date(2000, 0, 1), "y d"); // 2000 1
162
164
163
-
formatDate(new Date(2000, 0, 1), "y dd"); // 2000 01
165
+
formatDate(new Date(2000, 0, 1), "y dd"); // 2000 01
164
166
165
167
***The `"E"` specifier**—Renders the day of the week.
166
168
167
169
For the abbreviated day name, use one through three letters. For the wide name, use four letters. For the narrow name, use five letters. For the short name, use six letters.
***The `"e"` specifier**—The same as the `"E"` specifier except that it adds a numeric value that depends on the local starting day of the week, using one or two letters. The format requires you to load the supplemental `weekData`.
180
182
181
-
import { formatDate } from '@telerik/kendo-intl';
183
+
import { formatDate } from '@telerik/kendo-intl';
182
184
183
-
formatDate(new Date(2000, 0, 1), "e"); // 7
185
+
formatDate(new Date(2000, 0, 1), "e"); // 7
184
186
185
187
***The `"c"` specifier**—The same as the `"e"` specifier except that uses the standalone names.
186
188
187
189
***The `"a"` specifier**—Renders the day period.
188
190
189
191
For the short name, use one through three letters. For the wide name, use four letters. For the narrow name, use five letters.
***The `"Z"` specifier**—Renders the timezone.
260
262
261
263
To show the ISO8601 basic format with hours and minutes, use one through three letters. For the long localized GMT format, use four letters. For the ISO8601 extended format, use five letters.
***The `"X"` specifier**—Renders the timezone.
272
274
273
275
For the ISO8601 basic format with hours and optional minutes, use one letter. For the ISO8601 basic format with hours and minutes, use two letters and four letters. For the ISO8601 extended format, use three and five letters.
274
276
275
277
When the local time offset is `0` (zero), use the ISO8601 UTC indicator `Z`.
276
278
277
-
import { formatDate } from '@telerik/kendo-intl';
279
+
import { formatDate } from '@telerik/kendo-intl';
278
280
279
-
formatDate(new Date(2000, 0, 1), "X"); // +02
281
+
formatDate(new Date(2000, 0, 1), "X"); // +02
280
282
281
-
formatDate(new Date(2000, 0, 1), "X"); // Z if zero offset
283
+
formatDate(new Date(2000, 0, 1), "X"); // Z if zero offset
***The `"x"` specifier**—The same as the `"X"` specifier except that the `"x"` specifier does not add the UTC indicator when the offset is `0` (zero).
288
290
@@ -294,25 +296,25 @@ The supported types of options are:
294
296
295
297
***Locale predefined formats**—Sets the format from the [`dateFormats`](http://www.unicode.org/reports/tr35/tr35-dates.html#dateFormats), [`timeFormats`](http://www.unicode.org/reports/tr35/tr35-dates.html#timeFormats), and [`dateTimeFormats`](http://www.unicode.org/reports/tr35/tr35-dates.html#dateTimeFormats) elements of the calendar.
formatDate(new Date(2000, 10, 6, 13), { datetime: "full" }); // Monday, November 6, 2000 at 1:00:00 PM GMT+02:00
305
+
formatDate(new Date(2000, 10, 6, 13), { datetime: "full" }); // Monday, November 6, 2000 at 1:00:00 PM GMT+02:00
304
306
305
307
***Skeleton formats**—Sets the format from the [`availableFormats`](http://www.unicode.org/reports/tr35/tr35-dates.html#availableFormats_appendItems) of the calendar based on the date fields that you want to display.
***Fields formats**—Similar to the skeleton formats except that you need to set the required fields by using separate options in the same way as the [`Intl.DateTimeFormat`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat) object.
0 commit comments