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

103
Visualizações
Format JS date.toLocaleString differently

var date = new Date();
date.setDate(date.getDate() + 1)


console.log(`streak=0; expires=${date.toLocaleString('en-us', {  weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' })}`);

In my output, I get streak=0; expires=Sunday, January 2, 2022

My question is:

How can I format the date like this:

Thu, 18 Dec 2013 12:00:00 UTC

(12 and UTC don't need to be included)

I want the date number to go first then the month, not the other way around.

I am doing this because I need it to be formatted like that for a cookie:

document.cookie = "username=John Doe; expires=Thu, 18 Dec 2013 12:00:00 UTC";

(w3schools)

Tell me if that's not how you use cookies.

about 4 years ago · Juan Pablo Isaza
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