电子表格中最近的时区更改? [英] Recent Timezone changes in spreadsheet?
问题描述
它只是我还是最近在Google上发生了一些变化?我有一个功能,它为编辑工作增加了一个时间戳,这个编辑工作得很好,并且就在前一天它打破了。
它打破了它用于标记时间在我的时区 - 正如我使用的函数格式所指定的那样,现在它似乎是格林尼治时间而不是GMT-8的时间戳。
函数happyFunTime(){
var s = SpreadsheetApp.getActiveSheet ();
var r = s.getActiveCell();
var columnNum = r.getColumn();
var timeLastCalledColumnOffset = getTimeLastCalledColumnOffset();
var rowNum = r.getRow();
if(rowNum <= 1)return;
timeLastCalledColumnOffset ++;
// set dateCell = J列的当前行
var dateCell = s.getRange(rowNum,timeLastCalledColumnOffset);
var tZone =GMT-8;
//将当前日期格式化为日期时间格式
var dateTime = Utilities.formatDate(new Date(),tZone,MMM-dd-yyyy h:mm a);
//设置单元格值。添加撇号以强制文本处理&保持电子表格不被重新格式化
dateCell.setValue('+ dateTime);
$ b
getTimeLastCalledColumnOffset()
是一个自定义函数,用于返回包含我感兴趣的值(J,因此在这种情况下为9)的列的数目。
是的,昨天有个问题,因为这个字符串GMT-2或GMT-0200一直工作正常,现在是错误的。
您可以更改这一行:
var tZone =GMT-8
到这一个
var tZone =GMT-08:00
或者你可以用这行代码得到时区:
var FUS1 = new Date()。toString()。substr(25,8); //我使用FUS1而不是tZone
// GMT-0800 - > GMT-08:00,...
var FUS1 = FUS1.substr(0,6)+':'+ FUS1.substr(6)
//将当前日期格式化为日期时间格式
var dateTime = Utilities.formatDate(new Date(),FUS1,MMM-dd-yyyy h:mm a);
或者您可以从这里写入您的时区:
http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
America / Dawson - > -08:00(我不知道你住在哪里:-()
和这个代码:
var dateTime = Utilities.formatDate(new Date(),America / Dawson,MMM-dd -yyyy h:mm a);
注意:如果您想格式化从DateBox(label,textbox,...)然后是最后一行,如下所示:
var dateTime = Utilities。 formatDate(新日期(e.paramameter.datebox),America / Dawson,MMM-dd-yyyy h:mm
Sergi
Is it just me or has something in Google changed recently? I have a function that adds a timestamp to edits that was working just fine, and just the other day it broke.
It broke in the sense that it used to stamp the time in my timezone - as is specified by the function formatting I use, Now it appears to be timestamping in GMT instead of GMT-8. Nothing has changed in my script, so what happened?
function happyFunTime() {
var s = SpreadsheetApp.getActiveSheet();
var r = s.getActiveCell();
var columnNum = r.getColumn();
var timeLastCalledColumnOffset = getTimeLastCalledColumnOffset();
var rowNum = r.getRow();
if (rowNum <=1) return;
timeLastCalledColumnOffset++;
// set dateCell = the current row at column J
var dateCell = s.getRange(rowNum, timeLastCalledColumnOffset);
var tZone= "GMT-8";
// Format the current date into datetime format
var dateTime = Utilities.formatDate(new Date(), tZone, "MMM-dd-yyyy h:mm a");
// Set the cell value. Add apostrophe to force text treatment & keep the spreadsheet from reformatting
dateCell.setValue("'" + dateTime);
}
getTimeLastCalledColumnOffset()
is a custom function to return a number of the column that contains the value I'm interested in (J, so 9 in this case).
Yes, there are a issue from yesterday because this string "GMT-2" or "GMT-0200" has been working fine and now is faulty.
You can change this line :
var tZone= "GMT-8"
to this one
var tZone= "GMT-08:00"
or you can get the time zone with this lines of code :
var FUS1 = new Date().toString().substr(25,8); // I use FUS1 instead of tZone
// GMT-0800 -> GMT-08:00 , ...
var FUS1 = FUS1.substr(0,6) + ':' + FUS1.substr(6)
// Format the current date into datetime format
var dateTime = Utilities.formatDate(new Date(), FUS1 , "MMM-dd-yyyy h:mm a");
or you can writte your time zone from here :
http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
"America/Dawson" -> -08:00 (I don't know where you live :-( )
and this code :
var dateTime = Utilities.formatDate(new Date(), "America/Dawson" , "MMM-dd-yyyy h:mm a");
Note: if you want to format a date captured from a DateBox (label, textbox, ...) then, the last line, can be something like:
var dateTime = Utilities.formatDate(new Date(e.paramameter.datebox), "America/Dawson" , "MMM-dd-yyyy h:mm
Sergi
这篇关于电子表格中最近的时区更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!