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
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