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

205
Views
¿Cómo obtener solo la parte de la fecha de GMT en JavaScript?

Aquí está mi cadena de fecha:

 2022-07-20T11:34:39

Y aquí está mi código para obtener GMT:

 new Date('2022-07-20T11:34:39').toGMTString() // prints this // Wed, 20 Jul 2022 07:04:39 GMT

Sin embargo, solo necesito la parte de la fecha. Wed, 20 Jul 2022 . Sé que puedo usar substring o regex o split, etc. para extraerlo.

¿Hay alguna solución para lograr esto sin esos trucos?

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

En primer lugar , toGMTString() está en desuso:

Nota: toGMTString() está en desuso y ya no debe usarse. Permanece implementado solo por compatibilidad con versiones anteriores; utilice toUTCString() en su lugar.

Está buscando toDateString() :

 const res = new Date('2022-07-20T11:34:39').toDateString() console.log(res)

O más configurable toLocaleDateString() :

 const options = { weekday: 'short', year: 'numeric', month: 'short', day: 'numeric' }; const res = new Date('2022-07-20T11:34:39').toLocaleDateString('en-US', options) console.log(res)

about 4 years ago · Santiago Trujillo Report

0

usar Intl.DateTimeFormat

 const dateFormatter = new Intl.DateTimeFormat('en-GB', { year: 'numeric', month: 'long', day: 'numeric', weekday: 'short' }) const dateFormatter2 = new Intl.DateTimeFormat('en-GB', { dateStyle: 'full' }) const cdate = new Date() console.log(dateFormatter.format(cdate)); console.log(dateFormatter2.format(cdate));

about 4 years ago · Santiago Trujillo 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!