[英]Google Sheets API v4 inserting new Date() in datetime format
The following code inserts new Date()
as Mon Sep 04 21:34:54 GMT+01:00 2017
以下代码将new Date()
插入为Mon Sep 04 21:34:54 GMT+01:00 2017
Using Google Sheets API v4, Sheets.Spreadsheets.Values.update 使用Google Sheets API v4,Sheets.Spreadsheets.Values.update
function withUpdate() {
var spreadsheetId = "someSpreadsheetId";
var request = {
majorDimension: "ROWS",
values: [[new Date()]]
};
Sheets.Spreadsheets.Values.update(
request,
spreadsheetId,
"Sheet1!BW20",
{valueInputOption: "USER_ENTERED"}
);
}
The following code inserts new Date()
as 04.09.2017 21:34:54
以下代码将new Date()
插入为04.09.2017 21:34:54
Using Google Apps Script, getRange().setValue 使用Google Apps脚本,getRange()。setValue
function withSetValue () {
var spreadsheet = SpreadsheetApp.openById("someSpreadsheetId")
var sheetOne = spreadsheetId.getSheetByName("Sheet1");
sheetOne.getRange(20, 75).setValue(new Date());
}
Is it possible to make [ie Google Sheets API v4] to insert new Date()
the same way as Google Apps Script inserts it in the following format: 04.09.2017 21:34:54
? 是否可以使[ie Google Sheets API v4]插入new Date()
的方式与Google Apps脚本以以下格式插入它的方式相同: 04.09.2017 21:34:54
? How to avoid getting this format Mon Sep 04 21:34:54 GMT+01:00 2017
with Values.update
? 如何避免使用Values.update
Mon Sep 04 21:34:54 GMT+01:00 2017
获得此格式?
Thank you. 谢谢。
通过使用以下命令找到了自己问题的答案:
Utilities.formatDate(new Date(), "GMT+1", "dd/MM/yy HH:mm:ss");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.