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

208
Views
¿Cómo obtener Mes-Año de una cadena de marca de tiempo?

Quiero obtener el Mes y el Año de una cadena de Marca de tiempo.

Intento :

 var x = "2021-09-08T17:00:00.000Z" x.toLocaleString('en-us',{month:'short', year:'numeric'}) console.log(x)`enter code here`

Resultado Esperado

 x = "September 2021"
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Puede lograr fácilmente este resultado usando el método getMonth() y getFullYear() del objeto Date

 const x = "2021-09-08T17:00:00.000Z"; const monthNames = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", ]; const date = new Date(x); const result = `${monthNames[date.getMonth()]} ${date.getFullYear()}`; console.log(result);

about 4 years ago · Juan Pablo Isaza Report

0

Puedes editar tu código de la siguiente manera

 var x = "2021-09-08T17:00:00.000Z" var monthYear = new Date(x).toLocaleString('en-us', { month: 'long', year: 'numeric' }) console.log(monthYear)

about 4 years ago · Juan Pablo Isaza Report

0

Primero debe analizarlo como un objeto de fecha.

 const x = "2021-09-08T17:00:00.000Z" const y = new Date(x)

entonces puedes usar los métodos de fecha.

 console.log(y.toLocaleString("en-us", { month: "long", year: "numeric" }));

salidas: September 2021

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