I'm using Date picker from Material UI. The code responsible for it looks like:
import { DatePicker } from 'redux-form-material-ui';
<Field
name="birthDate"
component={DatePicker}
placeholder="Birth Date"
container="inline"
format={ null }
/>
It's a lil' bit changed, by erikras for redux form, but works quite similar like normal material ui date picker.
http://www.material-ui.com/#/components/date-picker
I'm sending it's value as API request, but unfortunately API accepts the Date only in YYYY-MM-DD
format. And MaterialUI date picker gives
2017-05-04T22:00:00.000Z
format. How can I change it into just 2017-05-04
?
Thank you so much!
I havent tried the library itself in depth however if it return that date in that format you could just take what you need from that if it is a string you could use the substring() method and giving it the desired part start and end. lets Say
result = 2017-05-04T22:00:00.000Z;
var stringNeeded = result.substring(0,10)
我认为,代替子字符串,最好使用一下矩库http://momentjs.com/ ,它可以将日期时间值格式化为您可以想象的任何格式moment(result).format('YYYY-MM-DD')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.