ant-design/components/date-picker/demo/presetted-ranges.md
Daniel Harrison c54bffb3e2 Update presetted-ranges.md (#18546)
Corrected english | presetted -> preset
2019-08-29 15:07:35 +08:00

984 B

order title
8
zh-CN en-US
预设范围 Preset Ranges

zh-CN

可以预设常用的日期范围以提高用户体验。

en-US

We can set preset ranges to RangePicker to improve user experience.

import { DatePicker } 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(
  <div>
    <RangePicker
      ranges={{
        Today: [moment(), moment()],
        'This Month': [moment().startOf('month'), moment().endOf('month')],
      }}
      onChange={onChange}
    />
    <br />
    <RangePicker
      ranges={{
        Today: [moment(), moment()],
        'This Month': [moment().startOf('month'), moment().endOf('month')],
      }}
      showTime
      format="YYYY/MM/DD HH:mm:ss"
      onChange={onChange}
    />
  </div>,
  mountNode,
);