react-bootstrap-datetimepicker
react-bootstrap-datetimepicker copied to clipboard
component doesn't work
I'm using the version 0.0.18 (Chrome browser)
- When I specify dateTime= date as a string it always shows "invalid date" (only dateTime=moment() works)
- Typing ANY text in the edit box shows "invalid date"
- onChange callback returns obscure values such as "1436964120000"
Not sure if it helps, but I had to set the inputFormat and format to the value I wanted in the textfield.
Example:
let value = "2015-01-01"
<DateTimeField
mode="date"
inputFormat="YYYY-MM-DD"
format="YYYY-MM-DD"
dateTime={value}
/>
Then the return value in your onChange function will change to the format you set in the format attribute.
Playing around, it seems that:
- When you specify
format, you must specify adateTimevalue too. (it's not defaulting tonow()using the right format but I was expecting it) - Since you specify
formatyourdateTimevalue must follow this format.
This results in a code like @Jhays10 wrote but format and inputFormat don't have to be the same:
let internalFormat = 'DD/MM/YY'; // I do this just to insist that format and inputFormat are different
let displayedFormat = 'YYYY/MM/DD';
let value = moment().format(internalFormat);
<DateTimeField
inputFormat={displayedFormat}
format={internalFormat}
dateTime={value}
/>
calling onChange will give you the date as internalFormat while the input field will display as inputFormat.
Hmm I'm guessing https://github.com/quri/react-bootstrap-datetimepicker#datetimefield isn't clear enough ?
Did you guys also had a look at the examples : http://dev.quri.com/react-bootstrap-datetimepicker/ ?