1

I'using this library for react time picker: https://github.com/YouCanBookMe/react-datetime But now I have 2 problems.

  1. The time (Am, Pm, HH:mm) in timepicker doesnt'work , because it doesn't change, it remain to 12 : 00 AM
  2. How correctly update state? because if I handle onChange (input manual write), it receive string, that I can't parse and it is invalid date.

My code is:

import DateTime from 'react-datetime';
var moment = require('moment');
handleChangeDate(propertyName, date) {
    const event = Object.assign({}, this.state.event);
    if (typeof date === 'string') {
        date = moment(date);
    }
    event[propertyName] = data.format('DD/MM/YYYY HH:mm');
    this.setState({ event: event });
}

and in Render() I have compoment:

<DateTime dateFormat={"dddd, MMM. Do YYYY, HH:mm (hh:mm a)"} value={this.state.event.to} onChange={this.handleChangeDate.bind(this, 'to')}/>

What is wrong?

LorenzoBerti
  • 6,704
  • 8
  • 47
  • 89

1 Answers1

0

check in below link. Customized calendar will solve your problem.

https://github.com/YouCanBookMe/react-datetime#customize-the-appearance

After choose date in calendar then click on date. It will show the edit option for time.

Example Link

https://codepen.io/simeg/pen/YppLmO

Let it try

vnomvk
  • 113
  • 5