You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.4 KiB

---
feat: New Picker (#20023) * init generate * basic style * basic panel style * update mode panel style * update style * generate More picker * default clear icon * chore: Update separator type * feat: Add ranged start & end className * update range style * Add transition effect * support size config * adjust range style * chore: Auto fill time by showTime * auto set time by format * update disabled style * update seperator style * ranges style * support extra footer style * remove useless test case part is not usable anymore part is already tested in rc-picker * init calendar * all demos * fix calendar basic test * fix time-picker test case * update snapshot * fix tooltip test case & lint * fix locale & style lint * fix compile * fix style * fix style lint * fix calendar style * update rc-picker version * adjust style * move picker placeholder into locale file * update snapshot * add hover style * update picker version * fix icon position & style * update picker version * update deps for pading * fix: align of suffix * feat: Year & Month support range effect * adjust range style to support up-down placement * update rc-picker * update range picker style * adjust extra footer line style * update snapshot * fix: Locale error * fix: style lint * fix: add missing button style deps * update test case * fix firefox additional white line style issue * rollback demo * fix ff additional blue color * docs: Remove placeholder in demo * rangepicker ranges is tag now * connect start / end background color with picker range * update deps * update deps for fixing blur text issue * hide start-end demo * range hover style update * hover range with ranged value * black magic of inner hover style * hover style of range adjust * fix css select miss hit on DatePicker * remove one eslint rule * fade range hovered color * week should alway not show the cell selection * update style of selection * update snapshot * fix style * add margin back * update rc-picker deps * update date & time picker & form style * fix disabled demo & update form style * update docs about allowEmpty * hide arrow in time range picker * add hover & focused style * fix lint * fix style & update snapshot * raise disabled selector proirity * fix disabled today border color * extra footer provides an bottom line * time picker hover support transition background * add padding style * fix Firefox not correct calculate inline-flex * fix style * fix week picker missing today border color * rm useless padding * Force padding to 0 * test coverage * dedup eslint rule * adjust logic to imporve coverage * fix render cell logic
5 years ago
order: 2
title:
zh-CN: 日期格式
en-US: Date Format
---
## zh-CN
使用 `format` 属性,可以自定义日期显示格式。
## en-US
We can set the date format by `format`.
```jsx
import { DatePicker, Space } from 'antd';
import moment from 'moment';
feat: New Picker (#20023) * init generate * basic style * basic panel style * update mode panel style * update style * generate More picker * default clear icon * chore: Update separator type * feat: Add ranged start & end className * update range style * Add transition effect * support size config * adjust range style * chore: Auto fill time by showTime * auto set time by format * update disabled style * update seperator style * ranges style * support extra footer style * remove useless test case part is not usable anymore part is already tested in rc-picker * init calendar * all demos * fix calendar basic test * fix time-picker test case * update snapshot * fix tooltip test case & lint * fix locale & style lint * fix compile * fix style * fix style lint * fix calendar style * update rc-picker version * adjust style * move picker placeholder into locale file * update snapshot * add hover style * update picker version * fix icon position & style * update picker version * update deps for pading * fix: align of suffix * feat: Year & Month support range effect * adjust range style to support up-down placement * update rc-picker * update range picker style * adjust extra footer line style * update snapshot * fix: Locale error * fix: style lint * fix: add missing button style deps * update test case * fix firefox additional white line style issue * rollback demo * fix ff additional blue color * docs: Remove placeholder in demo * rangepicker ranges is tag now * connect start / end background color with picker range * update deps * update deps for fixing blur text issue * hide start-end demo * range hover style update * hover range with ranged value * black magic of inner hover style * hover style of range adjust * fix css select miss hit on DatePicker * remove one eslint rule * fade range hovered color * week should alway not show the cell selection * update style of selection * update snapshot * fix style * add margin back * update rc-picker deps * update date & time picker & form style * fix disabled demo & update form style * update docs about allowEmpty * hide arrow in time range picker * add hover & focused style * fix lint * fix style & update snapshot * raise disabled selector proirity * fix disabled today border color * extra footer provides an bottom line * time picker hover support transition background * add padding style * fix Firefox not correct calculate inline-flex * fix style * fix week picker missing today border color * rm useless padding * Force padding to 0 * test coverage * dedup eslint rule * adjust logic to imporve coverage * fix render cell logic
5 years ago
const { RangePicker } = DatePicker;
const dateFormat = 'YYYY/MM/DD';
docs: add DatePicker format demo(Week start ~ end) (#32078) * feat: doc of week format in date-picker * feat: doc of week format in date-picker * fix: set the tree-switcher-leaf-line position (#32075) * fix(image): small size hide preview text (#29900) * fix(image): small size hide preview text * fix: image preview text ellipsis * fix: reset test * chore: improve icon search experience (#32098) * chore: improve icon search experience close #32097 * chore: search result empty data * feat: Georgian translation (#32106) * parent 18cd40167857648ff48f6f8db229e5fea7608922 author Primlx <primulax@live.com> 1628778277 +0400 committer primulax <primulax@live.com> 1631181358 +0400 Add files via upload add georgian translation Create ka_GE.tsx Create ka_GE Rename ka_GE to ka_GE.tsx Create ka_GE.tsx Update ka_GE.tsx Update ka_GE.tsx Create ka_GE.tsx update rc-picker version Create ka_GE.tsx Create ka_GE Rename ka_GE to ka_GE.tsx Update ka_GE.tsx Update ka_GE.tsx Create ka_GE.tsx update rc-picker version * Update package.json Co-authored-by: Amumu <yoyo837@hotmail.com> * test case * add language option in markdown * test * Update components/calendar/locale/ka_GE.tsx Co-authored-by: Amumu <yoyo837@hotmail.com> * Update components/calendar/locale/ka_GE.tsx Co-authored-by: Amumu <yoyo837@hotmail.com> Co-authored-by: Amumu <yoyo837@hotmail.com> * docs: Update research-message-and-feedback.zh-CN.md (#32112) * fix: Use latest rc-picker version with defaultPickerValue/showTime fix (#32107) * update rc-picker dependency to 2.5.17 * add test: DatePicker.RangePicker with defaultPickerValue and showTime * fix: missing `default.css` (#32116) * chore: Add CI for compile * chore: Add missing compile file * docs: fix typo (#32121) * fix: preserve table pagination className (#32131) close #32130 * fix: use well typed PaginationLocale from rc-pagination (#32128) * docs: fix typo * fix: useMessage() should use getPopupContainer from <ConfigProvider />… (#31939) * fix:useMessage() should use getPopupContainer from <ConfigProvider /> #31841 * fix: useMessage() should use getPopupContainer from <ConfigProvider /> #31841 * add test case for useMessage hook * restore some changes * try to restore files agains * restore and keep the same as upstream master * restore files * restore some definition * feat: inherit rc-pagination props, more customizable (#32132) * feat: inherit rc-pagination props, more customizable close #32128, #32129 * chore: CustomSelect.Option is required by rc-pagination * fix: LocaleReceivier types issue * fix: lint issue, pageSize must be presented * chore: add Button.shape 'default' definition (#32004) * feat: add Button.shape 'default' * fix: ignore shape when falsy value * fix: generate className only when shape match * fix: remove necessary .ant-btn-default and update snapshot * fix: Cascader missing props (#32143) * fix: Cascader deps * docs: Update using new API * test: Test case cover * chore: compressed skip dup check * chore: remove redundant space after `should` (#32141) * chore(deps-dev): bump eslint-plugin-unicorn from 35.0.0 to 36.0.0 (#32149) Bumps [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn) from 35.0.0 to 36.0.0. - [Release notes](https://github.com/sindresorhus/eslint-plugin-unicorn/releases) - [Commits](https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v35.0.0...v36.0.0) --- updated-dependencies: - dependency-name: eslint-plugin-unicorn dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: fix modal demo in small screen * refactor(dropdown): add dropdownButtonType export and refactor defaultProps (#31957) Co-authored-by: btea <2356281422@qq.com> Co-authored-by: drizzlesconsin <69514654+drizzlesconsin@users.noreply.github.com> Co-authored-by: afc163 <afc163@gmail.com> Co-authored-by: Primlx <primulax@live.com> Co-authored-by: Amumu <yoyo837@hotmail.com> Co-authored-by: in_vane <52909860+in-vane@users.noreply.github.com> Co-authored-by: Thomas Zipner <thomas.zipner@gmail.com> Co-authored-by: 二货机器人 <smith3816@gmail.com> Co-authored-by: MD. Ariful Alam <swazan.arif@gmail.com> Co-authored-by: JounQin <admin@1stg.me> Co-authored-by: James <daoxingyue@live.cn> Co-authored-by: 绯一 <jaredleechn@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Zuobin Wang <49583235+Dreamerryao@users.noreply.github.com>
3 years ago
const weekFormat = 'MM/DD';
const monthFormat = 'YYYY/MM';
const dateFormatList = ['DD/MM/YYYY', 'DD/MM/YY'];
const customFormat = value => `custom format: ${value.format(dateFormat)}`;
docs: add DatePicker format demo(Week start ~ end) (#32078) * feat: doc of week format in date-picker * feat: doc of week format in date-picker * fix: set the tree-switcher-leaf-line position (#32075) * fix(image): small size hide preview text (#29900) * fix(image): small size hide preview text * fix: image preview text ellipsis * fix: reset test * chore: improve icon search experience (#32098) * chore: improve icon search experience close #32097 * chore: search result empty data * feat: Georgian translation (#32106) * parent 18cd40167857648ff48f6f8db229e5fea7608922 author Primlx <primulax@live.com> 1628778277 +0400 committer primulax <primulax@live.com> 1631181358 +0400 Add files via upload add georgian translation Create ka_GE.tsx Create ka_GE Rename ka_GE to ka_GE.tsx Create ka_GE.tsx Update ka_GE.tsx Update ka_GE.tsx Create ka_GE.tsx update rc-picker version Create ka_GE.tsx Create ka_GE Rename ka_GE to ka_GE.tsx Update ka_GE.tsx Update ka_GE.tsx Create ka_GE.tsx update rc-picker version * Update package.json Co-authored-by: Amumu <yoyo837@hotmail.com> * test case * add language option in markdown * test * Update components/calendar/locale/ka_GE.tsx Co-authored-by: Amumu <yoyo837@hotmail.com> * Update components/calendar/locale/ka_GE.tsx Co-authored-by: Amumu <yoyo837@hotmail.com> Co-authored-by: Amumu <yoyo837@hotmail.com> * docs: Update research-message-and-feedback.zh-CN.md (#32112) * fix: Use latest rc-picker version with defaultPickerValue/showTime fix (#32107) * update rc-picker dependency to 2.5.17 * add test: DatePicker.RangePicker with defaultPickerValue and showTime * fix: missing `default.css` (#32116) * chore: Add CI for compile * chore: Add missing compile file * docs: fix typo (#32121) * fix: preserve table pagination className (#32131) close #32130 * fix: use well typed PaginationLocale from rc-pagination (#32128) * docs: fix typo * fix: useMessage() should use getPopupContainer from <ConfigProvider />… (#31939) * fix:useMessage() should use getPopupContainer from <ConfigProvider /> #31841 * fix: useMessage() should use getPopupContainer from <ConfigProvider /> #31841 * add test case for useMessage hook * restore some changes * try to restore files agains * restore and keep the same as upstream master * restore files * restore some definition * feat: inherit rc-pagination props, more customizable (#32132) * feat: inherit rc-pagination props, more customizable close #32128, #32129 * chore: CustomSelect.Option is required by rc-pagination * fix: LocaleReceivier types issue * fix: lint issue, pageSize must be presented * chore: add Button.shape 'default' definition (#32004) * feat: add Button.shape 'default' * fix: ignore shape when falsy value * fix: generate className only when shape match * fix: remove necessary .ant-btn-default and update snapshot * fix: Cascader missing props (#32143) * fix: Cascader deps * docs: Update using new API * test: Test case cover * chore: compressed skip dup check * chore: remove redundant space after `should` (#32141) * chore(deps-dev): bump eslint-plugin-unicorn from 35.0.0 to 36.0.0 (#32149) Bumps [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn) from 35.0.0 to 36.0.0. - [Release notes](https://github.com/sindresorhus/eslint-plugin-unicorn/releases) - [Commits](https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v35.0.0...v36.0.0) --- updated-dependencies: - dependency-name: eslint-plugin-unicorn dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: fix modal demo in small screen * refactor(dropdown): add dropdownButtonType export and refactor defaultProps (#31957) Co-authored-by: btea <2356281422@qq.com> Co-authored-by: drizzlesconsin <69514654+drizzlesconsin@users.noreply.github.com> Co-authored-by: afc163 <afc163@gmail.com> Co-authored-by: Primlx <primulax@live.com> Co-authored-by: Amumu <yoyo837@hotmail.com> Co-authored-by: in_vane <52909860+in-vane@users.noreply.github.com> Co-authored-by: Thomas Zipner <thomas.zipner@gmail.com> Co-authored-by: 二货机器人 <smith3816@gmail.com> Co-authored-by: MD. Ariful Alam <swazan.arif@gmail.com> Co-authored-by: JounQin <admin@1stg.me> Co-authored-by: James <daoxingyue@live.cn> Co-authored-by: 绯一 <jaredleechn@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Zuobin Wang <49583235+Dreamerryao@users.noreply.github.com>
3 years ago
const customWeekStartEndFormat = value =>
`${moment(value).startOf('week').format(weekFormat)} ~ ${moment(value)
.endOf('week')
.format(weekFormat)}`;
ReactDOM.render(
<Space direction="vertical" size={12}>
<DatePicker defaultValue={moment('2015/01/01', dateFormat)} format={dateFormat} />
<DatePicker defaultValue={moment('01/01/2015', dateFormatList[0])} format={dateFormatList} />
feat: New Picker (#20023) * init generate * basic style * basic panel style * update mode panel style * update style * generate More picker * default clear icon * chore: Update separator type * feat: Add ranged start &amp; end className * update range style * Add transition effect * support size config * adjust range style * chore: Auto fill time by showTime * auto set time by format * update disabled style * update seperator style * ranges style * support extra footer style * remove useless test case part is not usable anymore part is already tested in rc-picker * init calendar * all demos * fix calendar basic test * fix time-picker test case * update snapshot * fix tooltip test case &amp; lint * fix locale &amp; style lint * fix compile * fix style * fix style lint * fix calendar style * update rc-picker version * adjust style * move picker placeholder into locale file * update snapshot * add hover style * update picker version * fix icon position &amp; style * update picker version * update deps for pading * fix: align of suffix * feat: Year &amp; Month support range effect * adjust range style to support up-down placement * update rc-picker * update range picker style * adjust extra footer line style * update snapshot * fix: Locale error * fix: style lint * fix: add missing button style deps * update test case * fix firefox additional white line style issue * rollback demo * fix ff additional blue color * docs: Remove placeholder in demo * rangepicker ranges is tag now * connect start / end background color with picker range * update deps * update deps for fixing blur text issue * hide start-end demo * range hover style update * hover range with ranged value * black magic of inner hover style * hover style of range adjust * fix css select miss hit on DatePicker * remove one eslint rule * fade range hovered color * week should alway not show the cell selection * update style of selection * update snapshot * fix style * add margin back * update rc-picker deps * update date &amp; time picker &amp; form style * fix disabled demo &amp; update form style * update docs about allowEmpty * hide arrow in time range picker * add hover &amp; focused style * fix lint * fix style &amp; update snapshot * raise disabled selector proirity * fix disabled today border color * extra footer provides an bottom line * time picker hover support transition background * add padding style * fix Firefox not correct calculate inline-flex * fix style * fix week picker missing today border color * rm useless padding * Force padding to 0 * test coverage * dedup eslint rule * adjust logic to imporve coverage * fix render cell logic
5 years ago
<DatePicker defaultValue={moment('2015/01', monthFormat)} format={monthFormat} picker="month" />
docs: add DatePicker format demo(Week start ~ end) (#32078) * feat: doc of week format in date-picker * feat: doc of week format in date-picker * fix: set the tree-switcher-leaf-line position (#32075) * fix(image): small size hide preview text (#29900) * fix(image): small size hide preview text * fix: image preview text ellipsis * fix: reset test * chore: improve icon search experience (#32098) * chore: improve icon search experience close #32097 * chore: search result empty data * feat: Georgian translation (#32106) * parent 18cd40167857648ff48f6f8db229e5fea7608922 author Primlx &lt;primulax@live.com&gt; 1628778277 +0400 committer primulax &lt;primulax@live.com&gt; 1631181358 +0400 Add files via upload add georgian translation Create ka_GE.tsx Create ka_GE Rename ka_GE to ka_GE.tsx Create ka_GE.tsx Update ka_GE.tsx Update ka_GE.tsx Create ka_GE.tsx update rc-picker version Create ka_GE.tsx Create ka_GE Rename ka_GE to ka_GE.tsx Update ka_GE.tsx Update ka_GE.tsx Create ka_GE.tsx update rc-picker version * Update package.json Co-authored-by: Amumu &lt;yoyo837@hotmail.com&gt; * test case * add language option in markdown * test * Update components/calendar/locale/ka_GE.tsx Co-authored-by: Amumu &lt;yoyo837@hotmail.com&gt; * Update components/calendar/locale/ka_GE.tsx Co-authored-by: Amumu &lt;yoyo837@hotmail.com&gt; Co-authored-by: Amumu &lt;yoyo837@hotmail.com&gt; * docs: Update research-message-and-feedback.zh-CN.md (#32112) * fix: Use latest rc-picker version with defaultPickerValue/showTime fix (#32107) * update rc-picker dependency to 2.5.17 * add test: DatePicker.RangePicker with defaultPickerValue and showTime * fix: missing `default.css` (#32116) * chore: Add CI for compile * chore: Add missing compile file * docs: fix typo (#32121) * fix: preserve table pagination className (#32131) close #32130 * fix: use well typed PaginationLocale from rc-pagination (#32128) * docs: fix typo * fix: useMessage() should use getPopupContainer from &lt;ConfigProvider /&gt;… (#31939) * fix:useMessage() should use getPopupContainer from &lt;ConfigProvider /&gt; #31841 * fix: useMessage() should use getPopupContainer from &lt;ConfigProvider /&gt; #31841 * add test case for useMessage hook * restore some changes * try to restore files agains * restore and keep the same as upstream master * restore files * restore some definition * feat: inherit rc-pagination props, more customizable (#32132) * feat: inherit rc-pagination props, more customizable close #32128, #32129 * chore: CustomSelect.Option is required by rc-pagination * fix: LocaleReceivier types issue * fix: lint issue, pageSize must be presented * chore: add Button.shape &#39;default&#39; definition (#32004) * feat: add Button.shape &#39;default&#39; * fix: ignore shape when falsy value * fix: generate className only when shape match * fix: remove necessary .ant-btn-default and update snapshot * fix: Cascader missing props (#32143) * fix: Cascader deps * docs: Update using new API * test: Test case cover * chore: compressed skip dup check * chore: remove redundant space after `should` (#32141) * chore(deps-dev): bump eslint-plugin-unicorn from 35.0.0 to 36.0.0 (#32149) Bumps [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn) from 35.0.0 to 36.0.0. - [Release notes](https://github.com/sindresorhus/eslint-plugin-unicorn/releases) - [Commits](https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v35.0.0...v36.0.0) --- updated-dependencies: - dependency-name: eslint-plugin-unicorn dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] &lt;support@github.com&gt; Co-authored-by: dependabot[bot] &lt;49699333+dependabot[bot]@users.noreply.github.com&gt; * chore: fix modal demo in small screen * refactor(dropdown): add dropdownButtonType export and refactor defaultProps (#31957) Co-authored-by: btea &lt;2356281422@qq.com&gt; Co-authored-by: drizzlesconsin &lt;69514654+drizzlesconsin@users.noreply.github.com&gt; Co-authored-by: afc163 &lt;afc163@gmail.com&gt; Co-authored-by: Primlx &lt;primulax@live.com&gt; Co-authored-by: Amumu &lt;yoyo837@hotmail.com&gt; Co-authored-by: in_vane &lt;52909860+in-vane@users.noreply.github.com&gt; Co-authored-by: Thomas Zipner &lt;thomas.zipner@gmail.com&gt; Co-authored-by: 二货机器人 &lt;smith3816@gmail.com&gt; Co-authored-by: MD. Ariful Alam &lt;swazan.arif@gmail.com&gt; Co-authored-by: JounQin &lt;admin@1stg.me&gt; Co-authored-by: James &lt;daoxingyue@live.cn&gt; Co-authored-by: 绯一 &lt;jaredleechn@users.noreply.github.com&gt; Co-authored-by: dependabot[bot] &lt;49699333+dependabot[bot]@users.noreply.github.com&gt; Co-authored-by: Zuobin Wang &lt;49583235+Dreamerryao@users.noreply.github.com&gt;
3 years ago
<DatePicker defaultValue={moment()} format={customWeekStartEndFormat} picker="week" />
<RangePicker
defaultValue={[moment('2015/01/01', dateFormat), moment('2015/01/01', dateFormat)]}
format={dateFormat}
/>
<DatePicker defaultValue={moment('2015/01/01', dateFormat)} format={customFormat} />
</Space>,
mountNode,
);
```