在谷歌表格上我有这个值
Id Date In Out
8 12/9/2016 22:00 22:00
50 12/5/2016 07:40 17:32
50 12/6/2016 07:41 17:42
50 12/7/2016 07:20 17:40
50 12/8/2016 07:22 20:56
50 12/9/2016 07:35 18:11
50 12/10/2016 07:31 07:31
50 12/11/2016 04:27 04:27
50 12/12/2016 07:52 18:02
当我检索 Google 网站的值时,它会将“进入时间”和“超时”转换为如下所示的内容
2016-12-09 Sat Dec 30 1899 21:54:38 GMT+0800 (HKT) Sat Dec 30 1899 21:54:38 GMT+0800 (HKT)
它将时间从 07:40 转换为 Sat Dec 30 1899 07:40:39 GMT+0800 (HKT)
如何将其恢复到上午 07:40 或 7:40?
这就是我获取值的方式:
var sheetToView = ss.getSheetByName("TempManila");
var rangeToView = sheetToView.getDataRange();
var values = rangeToView.getValues();
values.shift();
var temp = new Array();
for(var i=0;i<values.length;i++){
temp.push([
values[i][0].toString(),
values[i][1].toString(),
values[i][2].toString(),
values[i][3].toString(),
values[i][4].toString(),
values[i][5].toString(),
values[i][6].toString(),
values[i][7].toString(),
values[i][8].toString(),
values[i][9].toString(),
]);
非常感谢。
最佳答案
将 .getValues() 更改为 . getDisplayValues()可能有帮助。 从文档来看:它...
returns the rectangular grid of values for this range. Returns a two-dimensional array of displayed values, indexed by row, then by column. The values will be of type String. The displayed value takes into account date, time and currency formatting, including formats applied automatically by the spreadsheet's locale setting.
关于javascript - 使用 .getValues 检索时,Google 工作表正在更改单元格值的格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42221496/