Tengo un valor de retorno de datos de API como ese: 2022-01-07T12:03:58.273Z Quiero cambiar esta fecha a 2022-01-07 12:03:58 . Mi código para convertir no funciona, este es mi código:
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)El resultado es:
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