ant-design/components/date-picker/demo/presetted-ranges.md
07akioni 5a08aab0e8
docs: DatePicker demo refactor (#25913)
* docs: DatePicker change type demo

* chore: snapshot

* chore

* docs: DatePicker use Space

* chore: snapshot
2020-07-30 19:17:34 +08:00

49 lines
1015 B
Markdown

---
order: 8
title:
zh-CN: 预设范围
en-US: Preset Ranges
---
## zh-CN
可以预设常用的日期范围以提高用户体验。
## en-US
We can set preset ranges to RangePicker to improve user experience.
```jsx
import { DatePicker, Space } from 'antd';
import moment from 'moment';
const { RangePicker } = DatePicker;
function onChange(dates, dateStrings) {
console.log('From: ', dates[0], ', to: ', dates[1]);
console.log('From: ', dateStrings[0], ', to: ', dateStrings[1]);
}
ReactDOM.render(
<Space direction="vertical" size={12}>
<RangePicker
ranges={{
Today: [moment(), moment()],
'This Month': [moment().startOf('month'), moment().endOf('month')],
}}
onChange={onChange}
/>
<RangePicker
ranges={{
Today: [moment(), moment()],
'This Month': [moment().startOf('month'), moment().endOf('month')],
}}
showTime
format="YYYY/MM/DD HH:mm:ss"
onChange={onChange}
/>
</Space>,
mountNode,
);
```