Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

104
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda