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/DateField.md
+12-3
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ title: "The DateField Component"
5
5
6
6
# `<DateField>`
7
7
8
-
Displays a dateor datetime using the browser locale (thanks to `Date.toLocaleDateString()`and `Date.toLocaleString()`).
8
+
Displays a date, datetime or time using the browser locale (thanks to `Date.toLocaleDateString()`, `Date.toLocaleString()`and `Date.toLocaleTimeString()`).
9
9
10
10
```jsx
11
11
import { DateField } from'react-admin';
@@ -19,13 +19,15 @@ import { DateField } from 'react-admin';
|`locales`| Optional | string | '' | Override the browser locale in the date formatting. Passed as first argument to `Intl.DateTimeFormat()`. |
21
21
|`options`| Optional | Object | - | Date formatting options. Passed as second argument to `Intl.DateTimeFormat()`. |
22
-
|`showTime`| Optional | boolean |`false`| If true, show date and time. If false, show only date |
22
+
|`showTime`| Optional | boolean |`false`| If true, show the time |
23
+
|`showDate`| Optional | boolean |`true`| If true, show the date |
24
+
23
25
24
26
`<DateField>` also accepts the [common field props](./Fields.md#common-field-props).
25
27
26
28
## Usage
27
29
28
-
This component accepts a `showTime` attribute (`false` by default) to force the display of time in addition to date. It uses `Intl.DateTimeFormat()` if available, passing the `locales` and `options` props as arguments. If Intl is not available, it ignores the `locales` and `options` props.
30
+
This component accepts `showTime` and `showDate` props to decide whether to display a date (`showTime=false` and `showDate=true`), a datetime (`showTime=true` and `showDate=true`) or time (`showTime=true` and `showDate=false`). Setting `showTime` and `showDate`to false at the same time will throw and error. It uses `Intl.DateTimeFormat()` if available, passing the `locales` and `options` props as arguments. If Intl is not available, it ignores the `locales` and `options` props.
29
31
30
32
{% raw %}
31
33
```jsx
@@ -37,6 +39,13 @@ This component accepts a `showTime` attribute (`false` by default) to force the
37
39
// renders the record { id: 1234, publication_date: new Date('2017-04-23 23:05') } as
0 commit comments