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

111
Views
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 answers
Answer question

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 Report
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!