Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

230
Vistas
One second time interval

In one of the filter options on my site, the user can select a date range and a time range. I have no problem with the date. But over time there is a question.

I am using the DatePicker from react-datepicker. To display the time, I use the format "HH:mm:ss" and added parameter timeIntervals={1}. Accordingly, the user can select the time with a frequency of one minute.

enter image description here

However, not in vain are the seconds nearby. And I would like to allow the user to select the time for each second. as below

enter image description here

There are no ready-made solutions in this library. And I could not find solutions on the Internet and any information in the documentation. Perhaps you can help me.

Below is my code

    export default function FilterDateTime({ isExpanded, setIsExpanded }) {
  const [startDate, setStartDate] = useState(new Date());
  const [endDate, setEndDate] = useState(new Date());
  
  const filterPassedTime = (time) => {
  const selectedDate = new Date(time);
  return selectedDate.getTime() > startDate.getTime();
  };


  return (
    <ArrowDropdown
        isExpanded={isExpanded}
        setIsExpanded={setIsExpanded}
        title="Date and Time range"
        onClick={() => setIsExpanded(!isExpanded)}>
                  <>
    <DatePicker

      selected={startDate}
      onChange={(date) => setStartDate(date)}
      showTimeSelect
      timeFormat="HH:mm:ss"
      timeIntervals={1}
      timeCaption="Time"
      dateFormat="dd/MM/yyyy         HH:mm:ss"
      calendarStartDay={1}
      onKeyDown={(e) => {e.preventDefault();}}
      selectsStart
      startDate={startDate}
      endDate={endDate}
    />
    
    <DatePicker
      selected={endDate}
      onChange={(date) => setEndDate(date)}
      showTimeSelect
      timeFormat="HH:mm:ss"
      timeIntervals={1}
      timeCaption="time"
      dateFormat="dd/MM/yyyy         HH:mm:ss"
      calendarStartDay={1}
      onKeyDown={(e) => {e.preventDefault();}}
      selectsEnd
      startDate={startDate}
      endDate={endDate}
      minDate={startDate}
      filterTime={filterPassedTime}
    />
    </>

    </ArrowDropdown>
  );
}

P.S. Since it is possible that this feature cannot be done. I can allow the user to enter seconds on their own (at the moment I have the input completely closed). But given the factor that a second in the end date cannot be less than a second in the start date.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This feature is currently not supported by react-datepicker but I can see the feature is already developed but is under PR review , might take some time to roll out.

Here is the github pr for same

https://github.com/Hacker0x01/react-datepicker/pull/3214

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda