'Old spreadsheets have wrong time and timezone .getValue() from cell
Problem: wrong time and timezone .getValue() from cell with format time
The bug occurs in old spreadsheets from 2017, but not a spreadsheet from 2022 january or new spreadsheets. update: it did appear in a new sheet as well
What steps will reproduce the problem?
- Spreadsheet settings -> timezone GMT+1 (your current timezone)
- in cell A1 write 20:00:00
- set format cell A1 to "time"
- execute this function in google apps script
function showTimeInCellA1() {
const date = SpreadsheetApp.getActiveSheet().getRange("A1").getValue();
SpreadsheetApp.getUi().alert("date in A1 is " + date);
}
- Problem: it will alert "date in A1 is Sat Dec 30 1899 19:09:21 GMT+0009"
Expected: I expected time 20:00:00 and GMT+1(because settings spreadsheet are GMT+1)
Solution 1:[1]
This appears to be a bug!
Leaving this here for future readers as I think this may have been reported by OP.
There is already a report on Google's Issue Tracker which detail the same kind of behaviour:
Google does seem to know about this issue but you can also hit the ? next to the issue number in the top left of the page so to let Google know more people are encountering the behaviour so it is more likely to be seen to faster.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | I hope this is helpful to you |
