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

254
Views
app script Convert Date from API to date specific

I have a return value from API data like that: 2022-01-07T12:03:58.273Z I want to change this date to 2022-01-07 12:03:58. My code to convert not working, this is my code:

    const txt = result.getContentText()
    const d = JSON.parse(txt)
    const time = d.status.timestamp;
    Logger.log(time)

    // get timezone
  var timeZone = Session.getScriptTimeZone();

  // convert date to another formate
  var formattedDate = Utilities.formatDate(time, timeZone, "yyyy-MM-dd _ HH:mm");
  Logger.log(formattedDate)

The result is:

Execution log
1:07:42 PM  Notice  Execution started
1:07:43 PM  Info    2022-01-07T12:07:43.172Z
1:07:44 PM  Error   
Exception: The parameters (String,String,String) don't match the method signature for Utilities.formatDate.
coData  @ Untitled.gs:27

enter image description here

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

0

Converting Date

function myfunk() {
  const time = new Date('2022-01-07T12:03:58.273Z');
  var timeZone = Session.getScriptTimeZone();
  var formattedDate = Utilities.formatDate(time, timeZone, "yyyy-MM-dd _ HH:mm");
  Logger.log(formattedDate)
}

Execution log
10:29:18 AM Notice  Execution started
10:29:18 AM Info    2022-01-07 _ 05:03
10:29:19 AM Notice  Execution completed
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!