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

119
Views
Google Apps Scripts Date conversions

I am populating a Google sheet with data from a JSON object I receive from Postman. Some of the information I receive is in this format:

{"attempt_starttime": "2021-09-21T03:28:13+0000",
 "attempt_endtime":"2021-09-21T03:28:35+0000",
 "invited_on":"2021-09-21T03:27:50+0000"}

I need to do some manipulations on them. What I want to know is

  1. How do I use an apps script to convert the data into a day of the week(Monday, Tuesday, etc.)
  2. How can I use apps script to do subtraction on the dates so I can get data like how long did it take the person to complete the task, how many days did it take to start the task after being invited, etc.

Thank you!

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

0

Adapt as you need ...

function chrono() {
  var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
  var jsonString = `{"attempt_starttime": "2021-09-21T03:28:13+0000",
 "attempt_endtime":"2021-09-21T03:28:35+0000",
 "invited_on":"2021-09-21T03:27:50+0000"}`
  var data = JSON.parse(jsonString)
  var startTime = new Date(data.attempt_starttime)
  var endTime = new Date(data.attempt_endtime)
  var invitedTime = new Date(data.invited_on)
  console.log(startTime + ' ... ' + days[startTime.getDay()])
  console.log(endTime + ' ... ' + days[endTime.getDay()])
  console.log(invitedTime + ' ... ' + days[invitedTime.getDay()])

  console.log(invitedTime.getUTCHours()); 
  console.log(invitedTime.getUTCMinutes());
  console.log(invitedTime.getUTCSeconds());

  console.log((startTime-invitedTime)/1000 + ' secondes')
  console.log((endTime-startTime)/1000 + ' secondes')
}
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!