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

336
Views
how can i format date returned form json

json returns years in this format

"dateOfBirth":"1997-03-23T08:00Z"

I need to convert the years to this format

var bDate = "3/23/1997";
var bDateformat = new Date(bDate).getTime() / 1000 | 0;
console.log("Birthday: "+bDateformat);

so in example i get returned value of

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

0

You can use this to output in JSON format:

var bDate = "3/23/1997";

new Date(bDate ).toJSON()
// result: '1997-03-22T19:30:00.000Z'

Or you can use this to get the date object from the JSON string:

var bDate = '1997-03-22T19:30:00.000Z';

new Date(bDate).toLocaleString()
// result: '3/23/1997, 12:00:00 AM'
about 4 years ago · Juan Pablo Isaza Report

0

This was also my question before, I have easily overcome this by using the Moment.js. It is easy to use and very understandable. Also, you can easily convert the patterns all together very simply.

Documentation on Moment.js

I don't know if your project is HTML and Javascript (or you are using node or ...), you can simply download (or install the package) the Moment.js and after including it in your project, the only thing you need to do is:

var bDate = "1997-03-23T08:00Z"
var newBDate = moment(bDate, "YYYY-MM-DDTHH:mm[Z]").format('M/DD/YYYY');
//Or you can use any other final date format as you want
console.log(newBDate)

This will help users to easily convert to any time format they want.

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!