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

171
Views
API Response Date Format

I'm using Google Apps Script making an API request to get a date. The date, however, is coming back as a number in scientific notation (1.635218706E9) which I'm assuming is in the format of milliseconds from 1970. After converting it from scientific notation to a regular number (1635218706) creating a new javascript date with it the wrong date and year. It should be Oct 25 2021, but instead gives Dec 31 1969.

Am I missing something when creating a new date from the number? And is there a way just have the API respond with a more readable date instead of milliseconds from 1970?

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

0

Just in case. I found if you multiply this number by 1000 and feed it to Data object you can get something a little bit more reasonable:

var seconds = 1.635218706E9;
var date = new Date(seconds*1000);
console.log(date); // output: 2021-10-26T03:25:06.000Z

var date_str = [date.getFullYear(), date.getMonth()+1, date.getDate()].join('/')
console.log(date_str); // output: 2021/10/26

It looks like the API gives you seconds.

about 4 years ago · Juan Pablo Isaza Report

0

you can use toLocaleString / toLocaleDateString

so the code is like this

const dates = new Date()
const fullDates = dates.toLocaleString('en-US')

you can read in documentation here : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString

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!