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

102
Views
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
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!