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

154
Views
Format JSON date to dsilay in html

I have some JSON that returns a simple date which I am placing in a DIV...

let movieDate = data.release_date;
document.getElementById('movie-date').innerHTML = movieDate;

The output is returned like this...

2021-07-14

I need to change this output to display in two different formats...

  • 14 June 2021
  • 2021

Is there a simple way to do this?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Probably the easiest is to use 3rd party library like day.js.

However can be achieved by:

const date = new Date('2021-07-14')

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

// "14 July 2021"
const sDate = `${date.getDate()} ${monthNames[date.getMonth()]} ${date.getFullYear()}`
console.log(sDate)

// 2021
console.log(date.getFullYear())

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!