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

172
Views
Parse int to date in a list of dictionaries

My list:

var list = [{"id": 1, "date": 1649368800000}, {"id": 2, "date": 1649368800000}, {"id": 3, "date": 1649368800000}]

Desired output:

var list = [{"id": 1, "date": 01.01.2022}, {"id": 2, "date": 1649368800000}, {"id": 3, "date": 01.01.2022}]

How can I effectively iterate through my list and parse my int values in "date" to a human readable date format?

For the start I tried to just print the date values..

var list_of_values = [a_dict["date"] for a_dict in list]

but failed with Parsing error: ',' expected

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

0

I think you're confusing python with javacript.

That short-for loop is the python way


Since you tagged this javacript, I'd recommend forEach() and new Date():


Parsed to date format

var list = [{"id": 1, "date": 1649368800000}, {"id": 2, "date": 1649368800000}, {"id": 3, "date": 1649368800000}];

list.forEach(o => o.date = new Date(o.date));

console.log(list);

Parsed to dd.mm.yyyy

var list = [{"id": 1, "date": 1649368800000}, {"id": 2, "date": 1649368800000}, {"id": 3, "date": 1649368800000}];

list.forEach(o => {
  const d = new Date(o.date);
  o.date = `${d.getDate()}.${d.getMonth() + 1}.${d.getFullYear()}`
});

console.log(list);

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!