I have wrote following script in my google sheet hoping to convert a timestamp in GMT to a customized timezone.
function myFunctions(datetimeString,timeZone,format) {
var moment = new Date(datetimeString);
return Utilities.formatDate(moment, timeZone, "yyyy-MM-dd'T'HH:mm:ss'Z'")
}
However, I have no idea why this function doesn't give me a correct timezone ! For instant, 6/30/2019 6:32:00 should return June 30, 2019 11:02 AM in (GMT+4:30), However, it returns wrong time (June 30, 2019 02:02).
I've wrote the script in script tools, and call myFunctions in googlesheet's cell (consider my timestamp is in A1):
=myFunctions(A1,Aisa/Tehran,"dd-MM-yyyy'T'HH:mm:ss'Z'")
Thanks in advance.