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

113
Vistas
Returning JavaScript as ddmmyyyy with zeros

I am still learning JS, but I am stuck on a little challenge where I need to output date to ddmmyyyy. Don't know really how do I add that or it's just a brain error.

This is as far as I have come:

var d= new Date(); var m=((d.getMonth()+1)<10)?'0'+(d.getMonth()+1):(d.getMonth()+1); return d.getDate() + m + d.getFullYear();

I tried adding .padStart(2, "0"); to the day, but it won't work and told that it's not a function.

Much appreciated!

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

0

Try this

var d= new Date();
var m=((d.getMonth()+1)<10)?'0'+(d.getMonth()+1):(d.getMonth()+1);
// See the changes in the line below    
console.log(d.getDate().toString().padStart(2, '0') + m + d.getFullYear());
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