[英]Google Sheets printing out date in milliseconds? Using google scripts (JavaScript)
So I am using google sheets with google scripts to sort some data and then put it into a new sheet. 所以我正在使用带有Google脚本的Google表格对一些数据进行排序,然后将其放入新的表格中。 I have been using the
.valueOf()
method to grab the data from an array that grabbed all the data using sheet.getDataRange().getValues();
我一直在使用
.valueOf()
方法从使用sheet.getDataRange().getValues();
所有数据的数组中捕获数据sheet.getDataRange().getValues();
and has worked perfectly with grabbing everything in all the other places besides my column containing the dates in the "dd/mm/yyyy"
order. 并且除了在我的按
"dd/mm/yyyy"
顺序排列的日期列之外,还可以完美地捕获所有其他地方的所有内容。 It grabs it but then puts it into my new sheet in the form of some massive number (which I think could possibly be seconds or milliseconds). 它抓住了它,然后以大量的形式(我认为可能是几秒钟或几毫秒)将其放入我的新工作表中。 I don't want a time stamp, I want to reverse whatever that time stamp thingy is.
我不想要一个时间戳,我想要颠倒不管那个时间戳。
Example: Original Date and After grabbing date and moving to new sheet 示例: 原始日期和获取日期之后并移至新表
Below I have posted the code I am using. 下面我发布了我正在使用的代码。 Any help or advice is greatly appreciated!
任何帮助或建议,我们将不胜感激!
Code: https://pastebin.com/snn3jDcH 代码: https : //pastebin.com/snn3jDcH
line where I grab the date:
for(var i = 1; i < data.length; i++) {
test = data[i][2].valueOf().substring(0,5);
if(test === "ES014")
{
DateStore[count] = data[i][0].valueOf();
NameStore[count] = data[i][1].valueOf();
NumStore[count] = data[i][2].valueOf();
QuantityStore[count] = data[i][3].valueOf();
count++;
}
Sorry about the formatting, but it wouldn't let me post unless I did it this way. 很抱歉格式化,但是除非我这样做,否则它不会让我发布。 No clue why but sorry!
不知道为什么,但是抱歉! Thank you for this long read!
感谢您的长期阅读!
Instead of sheet.getDataRange().getValues();
代替
sheet.getDataRange().getValues();
and then doing valueOf()
然后做
valueOf()
Simply only do sheet.getDataRange().getDisplayValues();
只需做
sheet.getDataRange().getDisplayValues();
and I think valueOf() is not necessary. 而且我认为valueOf()是没有必要的。
For further informations check this out 有关更多信息,请查看此
https://developers.google.com/apps-script/reference/spreadsheet/range#getdisplayvalues https://developers.google.com/apps-script/reference/spreadsheet/range#getdisplayvalues
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.