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

119
Vistas
How to change format of Date constructor in my date range slider

I'm currently using jquery ui slider plugin to set a range between two dates. I need the date output to be YYYY-MM-DD instead of fully written out like Mon Nov 29, 2021.

I'm using this function I found on codepen to convert the default jquery range slider into a date range slider between two dates. Right now the output of the dates is written out fully like I showed above. I need it to be in the format of YYYY-MM-DD. I tried changing min, max and the values options to new Date().toISOString().slice(0, 10), but it gave me an invalid date error. If anyone knows how to change the date format to be YYYY-MM-DD, it would be greatly appreciated!

  $(function() {
    $( "#slider-range" ).slider({
      range: true,
      min: new Date('2010.01.01').getTime() / 1000,
      max: new Date('2014.01.01').getTime() / 1000,
      step: 86400,
      values: [ new Date('2013.01.01').getTime() / 1000, new Date('2013.02.01').getTime() / 1000 ],
      slide: function( event, ui ) {
        $( "#amount" ).val( (new Date(ui.values[ 0 ] *1000).toDateString() ) + " - " + (new Date(ui.values[ 1 ] *1000)).toDateString() );
      }
    });
    $( "#amount" ).val( (new Date($( "#slider-range" ).slider( "values", 0 )*1000).toDateString()) +
      " - " + (new Date($( "#slider-range" ).slider( "values", 1 )*1000)).toDateString());
  });

Heres a link to the codepen I'm going off of. https://codepen.io/2rod/pen/JtIki

about 4 years ago · Juan Pablo Isaza
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