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

107
Views
invalid date format in javascript Date(2022,0,13) format

i am getting

{
  "LeadCreatedDate": "Date(2022,0,13)" // <----- this type of date format
}

image is there any way i can format it in react any kind of help will be great. Thank you in advance.

date format image link

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

0

If you cannot do anything about the format of the API response, you'll have to manually parse it.

For example, you can use slice() to extract the arguments part, split() them on comma characters to get an array, map() that to numbers and pass them to the Date constructor.

// a function to transform your date values
const parseGSheetDate = (val) =>
  new Date(...val.slice(5, -1).split(",").map(Number));

// your original data
const data = {
  "LeadCreatedDate": "Date(2022,0,13)",
  "FullName": "Maryn Mccabe",
  "FirstName": "Maryn",
  "LastName": "Mccabe",
};

// replace the date fields with their parsed equivalents
const parsed = {
  ...data,
  LeadCreatedDate: parseGSheetDate(data.LeadCreatedDate),
};

console.log(parsed);

about 4 years ago · Juan Pablo Isaza Report

0

To do that, you need to format date before you push data. There is an information, how to do that properly

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!