The following code was almost exactly what I was looking for to timestamp the adjacent cell after being edited. However, I need to incorporate the currnet date as well as time. The code below gives a date "1899".
What do I need to edit or is there a better code?
function onEdit() {
var s = SpreadsheetApp.getActiveSheet();
if ( s.getName() == "Sheet1" ) { //checks that we're on the correct sheet
var r = s.getActiveCell();
if ( r.getColumn() == 13 ) { //checks the column
var nextCell = r.offset(0, 1);
if ( nextCell.getValue() === '' ) //is empty?
var time = new Date();
time = Utilities.formatDate(time, "GMT", "HH:mm:ss");
nextCell.setValue(time);
};
};
}
Best Answer
If you need to display date along with the timestamp, then look at this line:
You can set this to whatever you like, in the year case try this:
If you are only concerned about displaying the year, then replace the
MM/DD/yy
info with justyyyy