我无法在电子表格单元格中获得时间戳格式来也包含时间。当前,它仅产生日期。我需要更改什么以使时间戳显示日期和时间?
像这样:
3/17/2015 10:57:45
function onEdit(event)
{
var ss = event.source.getActiveSheet();
var r = event.source.getActiveRange();
if(r.getColumn() == 8){ //To check if update cell in Column, 1 means first column.
if(r.getValue() == "Resolved"){ //To check the value is equal to Resolved
ss.getRange('L'+r.getRow()).setValue(new Date()); //Set column B1 value to current date.
date = Utilities.formatDate(time, "GMT", "HH:mm:ss");
}else{
ss.getRange('L'+r.getRow()).setValue('');
}
}
最佳答案
您需要使用:
var formattedDate = Utilities.formatDate(time, "GMT", "MM-dd-yyyy HH:mm:ss");
文档中有一个示例:
Google Documentation - formatDate
关于javascript - 时间戳记日期和时间格式-Apps脚本-格式化日期和时间,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29103235/