I am running React Datepicker and I'm getting the dates correctly, but the times are eluding me.
In the constructor I set the time like this
constructor(props) { super(props); this.state = { startdate: moment('20180702', 'YYYYMMDD'), starttime: moment('1122', 'HHmm'), }; } } Later in my component render I have (parameters are explained in the React DatePicker docs). This is not really of importance for my problem but I'm sharing it anyway. My problem is mostly on that moment instatiation in my constructor:
<DatePicker customInput={<StartTime />} popperClassName={classes.datepickerCalendar} isClearable selected={this.state.starttime} onChange={this.handleStartTimeChange} showTimeSelect showTimeSelectOnly timeIntervals={15} timeFormat="HH:mm" timeCaption="Time" /> The date is giving me an output of 07/020/2018 but the time is giving me some random or odd date as well, not an actual time. More specifically 11:22
I'm positive I am instatiating time incorrectly but I can't find an example in momentjs documentation.
How can I tell moment to display a time (i.e. 11:22)?