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

155
Views
I'm trying to convert an ISO date from an API to alphabetical months, how can you do it?

I'm trying to convert the following date I'm getting from the API:

2022-04-01T05:09:09.403Z

To the next one:

July 19, 2021

But I don't know how to do it. I've tried this so far:

  const months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]

for (var i = 0; i < postsResults.length; i++) {
  const trimmedData = postsResults[i].last_posted_at
  const finalData = trimmedData.substring(0, 10);
  let monthDate = finalData.slice(5,7)
  if (monthDate.includes(0)) {
    monthDate = finalData.slice(6,7)
  } else {
    monthDate = finalData.slice(5,7)
  }
  result = months[monthDate]
}

Postsresults is the array that I'm fetching. I'm slicing certain characters until I get the exact letters to match the months. This doesn't work as it always returns April.

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