DatePicker can not load date
See original GitHub issueVersion
2.7.4
Environment
win7 chrome
Reproduction link
http:none
Steps to reproduce
import React , { Component } from 'react';
import { Form , Icon , Input , Button , DatePicker } from 'antd';
import moment from 'moment';
const FormItem = Form.Item;
class Test extends Component {
componentDidMount(){
const { setFieldValue , setFieldsValue } = this.props.form;
// can not load this date
setFieldsValue({username:'admin',password:'abcde',date:1491462025480})
}
handleSubmit = (e)=>{
e.preventDefault();
this.props.form.validateFields((e,value)=>{
if(e)return;
console.info('value=>',value)
})
}
render(){
const { getFieldDecorator } = this.props.form;
return (
<div>
<Form layout="horizontal" onSubmit={::this.handleSubmit}>
<FormItem>
{getFieldDecorator('date',{
rules:[{required:true}]
})(
<DatePicker format={`YYYY-MM-DD HH:mm:ss`} />
)}
</FormItem>
<Button htmlType="submit" type="primary">submit</Button>
</Form>
</div>
)
}
}
export default Form.create({})(Test);
What is expected?
load date correctly
What is actually happening?
can not load date
antd@2.8.3 errMsg => inputValue.format is not a function
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
jquery - Datepicker won't load Properly - Stack Overflow
Hi I'm working with project, I have a problem with bootstrap datepicker it's not displaying properly, I don ...
Read more ><input type="date"> - HTML: HyperText Markup Language
Even though the date picker doesn't use it, the text input fallback will. For example, try viewing the following in an unsupporting browser:....
Read more >Solved: Date is not appearing as date field in datepicker
i want to use the datepicker, but nothing is appearing as datefield. start and endate are saved like this in the database: 2021-07-13...
Read more >Date Picker Dialog Example | APG | WAI - W3C
When the dialog is opened, if the input field is empty, or does not contain a valid date, then the current date is...
Read more >Datepicker Widget - jQuery UI API Documentation
The jQuery UI Datepicker is a highly configurable plugin that adds datepicker functionality to your pages. You can customize the date format and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
try this:
value
ofDatePicker
only support typemoment
. https://ant.design/components/date-picker/#DatePicker