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

193
Views
how to display the date as a day/month/year format after adding 10 days to current date

so I got this function that adds 5 days to the current date, the only problem is that the date is displayed as "Mon May 30 2022 00:16:04 GMT+0300 (Eastern European Summer Time)" I need a simple, clean format like 22/07/2002.

<div class="container-date">
  <p>Offer expires on <span id="date"></span></p>
</div>


ar d = new Date();
d.setDate(d.getDate() + 10);

document.getElementById("date").innerHTML = d ;
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

SUGGESTION

You can use formatDate(date, timeZone, format) method to easily format date objects. See this quick sample below:

SCRIPT

function test() {
  var d = new Date();
  var formattedDate = Utilities.formatDate(new Date(d.setDate(d.getDate() + 5)), Session.getScriptTimeZone(), "dd/MM/yyyy")
  console.log(formattedDate);
}

Demo:

enter image description here

about 4 years ago · Juan Pablo Isaza Report

0

Try this

// Note this wont calculate 5days ahead ,it just gives the asked format!
var today = new Date();   
var dd = String(today.getDate()).padStart(2,'0');  
to the current date
var mm = String(today.getMonth()+1).padStart(2,'0');  
var yyyy = today.getFullYear();    
today = dd + '/' + mm + '/' + yyyy;    
console.log(today);
about 4 years ago · Juan Pablo Isaza Report

0

date.toISOString().slice(0, 10): Convert date to string and get first 10 character. toISOString() (2022-05-29T23:03:31.782Z to 2022-05-29)

date.split('-').reverse().join('/'): Split string by -, reverseit for formatting and convert array to a string with / separator. (2022-05-29 to 29/05/2022)

const addDays = (days) => {
  let date = new Date();
  date.setDate(date.getDate() + days);
  date = date.toISOString().slice(0, 10);
  return date.split('-').reverse().join('/');
}
const date = addDays(5);
console.log(date);

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!