Hi can someone help me why minutes come as separated while changing I have this input
<input
type='time'
name='appt-time'
onChange={handleTimeChange}
value={getTime(datetime)}
/>;
and this function
const [hours, setHours] = useState(hour);
const [newMinutes, setMinutes] = useState(minutes);
const handleTimeChange = (event) => {
const time = event.target.value;
const newTime = time.split(':');
const hour = newTime[0];
const min = newTime[1];
console.log(min);
const newDatetime = format(new Date(), 'eee MMM dd yyyy ') + hour + ':' + min;
const newTimestamp = new Date(newDatetime).getTime();
const timestampNow = new Date().getTime();
const isTimeValid = newTimestamp >= timestampNow;
if (time) {
if (isTimeValid) {
setShowError(false);
const newDatetime = format(new Date(datetime), "yyyy-MM-dd'T'") + time;
const timeConverted = new Date(newDatetime).getTime();
setHours(hour);
if (min > 60) {
min = 59;
}
setMinutes(min);
setDatetime(timeConverted);
if (hour === hours && min > 9) {
event.target.blur();
}
} else {
setShowError(true);
event.preventDefault();
}
}
};
How can I make that min that is on console come as 29 for example not first 2 than 9, as you can see I tried using blur to make validation for 99, it taps outside, but then whith arrow up down wont work