-6

I got this JS code:

var d = new Date();
  
d.setDate(d.getDate() + (1 + 7 - d.getDay()) % 7);
 
  document.write(d);

and I want JS to display it in dd/mm/yyyy. How can I do that?

Thank you, Till

Script47
  • 14,230
  • 4
  • 45
  • 66
till36
  • 75
  • 1
  • 8
  • 2
    Please [search](/help/searching) before posting. **Every** conceivable "How do I format this date in JavaScript?" question has been asked and answered long since. Also do thorough research before posting, as even outside SO, this topic is **very** thoroughly covered. – T.J. Crowder Aug 25 '17 at 12:49
  • 1
    moment().add( 7, "days" ).format("DD/MM/YYYY"). Don't reinvent the wheel and check out momentJS. (Deja vu today, isn't it?) – Jeremy Thille Aug 25 '17 at 12:51
  • 1
    Your solution is previously asked stackoverflow question. https://stackoverflow.com/questions/1531093/how-do-i-get-the-current-date-in-javascript Please search directory before asking the question. – ksilentstorm Aug 25 '17 at 12:58

1 Answers1

-2

Try this link to W3 Schools date formatting:

https://www.w3schools.com/js/js_date_formats.asp

and date methods:

https://www.w3schools.com/js/js_date_methods.asp

and check out this previous S/O answer:

How to convert a full date to a short date in javascript?

Mike Cave
  • 147
  • 1
  • 4
  • 18