Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

171
Views
Input type time when I split it and use it handle change react minutes come separated numbers

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

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!