0

column A contains dates (UTC formatted) that I wish to format to a particular timezone, although the function is not returning the correct local formatted date.

function LOCALTIME(datetimeString) {
  var originalDate = new Date(datetimeString);
  return Utilities.formatDate(originalDate, "Australia/Adelaide", "YYYY-MM-DD HH:mm:ss")
}

enter image description here

15
  • Although I'm not sure whether this is the direct solution of your issue, when YYYY-MM-DD HH:mm:ss is modified to yyyy/MM/dd HH:mm:ss, what result will you get? Ref1 And, also "Australia/Adelaide" might be SpreadsheetApp.getActiveSpreadsheet().getSpreadsheetTimeZone(). Ref2 Commented May 20, 2020 at 1:10
  • Also, this thread might be useful. stackoverflow.com/q/28956532/7108653 Commented May 20, 2020 at 1:19
  • your suggestion has addressed the formatting issue, but it hasn't converted the time to "Australia/Adelaide" even when updating to ...getSpreadsheetTimeZone() Commented May 20, 2020 at 1:21
  • Thank you for replying. I apologize for the inconvenience. When Australia/Adelaide is modified to UTC+09:30, what result will you get? Commented May 20, 2020 at 1:39
  • This 2020-05-20T01:46:00.929Z converted to 2020-05-19 16:16:01, should have been 2020-05-20 10:16:01 that is approx 19 hours behind. It's currently not being converted to the correct timezone of Australia/Adelaide for some reason Commented May 20, 2020 at 1:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.