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

192
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
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