Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

120
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda