react-datetime icon indicating copy to clipboard operation
react-datetime copied to clipboard

Time picker does not update properly

Open Shenmin-Z opened this issue 9 years ago • 6 comments

Bug:

When the input is changed from e.g. "01/26/2017 :00 PM" to "01/26/2017 1:00 PM", the time picker won't update from 'AM' to 'PM'.

Shenmin-Z avatar Jan 06 '17 15:01 Shenmin-Z

Hi @Shenmin-Z.

Your example doesn't really make sense, what is :00 PM? This example is working. Could you provide a demo so I can see what props and values you are using?

simeg avatar Jan 06 '17 20:01 simeg

agent-date

Hi @simeg , thanks for you reply.

:00 PM doesn't make sense. But when it is changed to 2:00PM, it is a valid time and time picker should display as 2:00PM. It looks like an INVALID PREVIOUS state is preventing a VALID CURRENT state from displaying properly.

The example you provided displays the same behavior.

Shenmin-Z avatar Jan 11 '17 18:01 Shenmin-Z

Thanks for the demo, I see the problem now.

simeg avatar Jan 11 '17 20:01 simeg

I have a similar issue using the component as a time picker only for hours in 12hs format. The value prop is linked to state value={this.state.hour} and I did a lot of tries with several strings, dates and moment objects like "11 pm", "23", new Date(y,m,d,h),new Date().setHours(23), moment(23,'H'), new Date().toString(), etc but the am/pm part wasn't reflecting the state value. I found that by setting the state twice makes it work properly, of course I'm not proud of the solution

this.setState({time: t}, () => {
    this.setState({time: t});     
});

screen shot 2017-03-22 at 16 52 12

sstawecki avatar Mar 22 '17 19:03 sstawecki

is there an official fix for this?

angelxmoreno avatar Dec 24 '19 22:12 angelxmoreno

Any fix for this issue? Working through forestry.io CMS isn't working, and they are officially aware of this, and have put disclaimers on their documentation page: https://forestry.io/docs/settings/fields/datetime/ The error goes beyond the 24h problem though, even regular AM/PM handling fails, as described in this ticket.

martinmuntzing avatar Mar 08 '23 22:03 martinmuntzing