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

395
Views
Strapi date format using javascript

I recieve this date format from strapi 2021-09-01T15:21:39.862Z how can i transform it to a DD/MM/YYYY format ?

<div class="post-date-article">{{ formatMyDate(article.published_at) }}</div>

formatMyDate(value){
     if (value) {
       return value;
      }
  }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Strapi are providing a date in ISO 8601 format, which is easy to parse using the JavaScript date object.

I'd suggest using Date.toLocaleDateString() to format the input date as DD/MM/YYYY. Using a locale of 'en-GB' will format the supplied date in this way.

You can pass other locales such as 'de-DE' to format the date in another way if you wish.

function formatMyDate(value, locale = 'en-GB') {
    return new Date(value).toLocaleDateString(locale);
}

const timestamp = '2021-09-01T15:21:39.862Z';
console.log('Timestamp:', timestamp);
console.log('Formatted date:', formatMyDate(timestamp));
.as-console-wrapper { max-height: 100% !important; top: 0; }

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!