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

274
Views
dateFormat not working -> TypeError: Invalid date

I'm trying to convert 2022-01-17T21:36:04.000Z into January 18th type format. I'm doing with the help of npm package dateFormat.

I'm able to achieve this easily with:

const date = dateFormat("2022-01-17T21:36:04.000Z", "mmmm dS");

But instead of hardcoding if I pass value like this, it doesn't seem to work.

 
const convertDate = (dateformat) => {
  

    const date = dateFormat(`"${dateformat}"`, "mmmm dS");
    console.log(date);

I'm getting TypeError: Invalid date.


console.log(`"${dateformat}"`)  // is giving me -> "2022-01-17T21:36:04.000Z"

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

0

Instead of

const date = dateFormat(`"${dateformat}"`, "mmmm dS");

use the variable directly:

const date = dateFormat(dateformat, "mmmm dS");
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!