react-bootstrap-datetimepicker icon indicating copy to clipboard operation
react-bootstrap-datetimepicker copied to clipboard

component doesn't work

Open conceptacid opened this issue 10 years ago • 3 comments

I'm using the version 0.0.18 (Chrome browser)

  1. When I specify dateTime= date as a string it always shows "invalid date" (only dateTime=moment() works)
  2. Typing ANY text in the edit box shows "invalid date"
  3. onChange callback returns obscure values such as "1436964120000"

conceptacid avatar Jul 20 '15 12:07 conceptacid

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.

Jhays10 avatar Jul 21 '15 15:07 Jhays10

Playing around, it seems that:

  • When you specify format, you must specify a dateTime value too. (it's not defaulting to now() using the right format but I was expecting it)
  • Since you specify format your dateTime value 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.

AoDev avatar Aug 14 '15 09:08 AoDev

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/ ?

chollier avatar Aug 14 '15 16:08 chollier