The code to achieve this is as follows:
var d = Utilities.formatDate(new Date(),"EST","EEE', 'MMM dd', 'yyyy' at 'HH:mm:ss");
EST stands for Eastern Standard Time (I'm based on E coast of the US)EEE gives the abbreviated 3 letter day of the week (e.g. Mon)
MMM gives the abbreviated 3 letter month of the year (e.g. Mar)
Then I modify my appendRow method to include the date variable "d" in the output. The code is as follows:
//apend row
sheet.appendRow([lastCell+1,d,textBoxValue1,textBoxValue2,textBoxValue3]);
So my contacts database now automatically adds a date/time stamp to each new entry I add, and looks like this:
References for this entry:
Stack Overflow on Javascript Date object
Stack Overflow on formatting Date object
Official Google documentation on formatDate
No comments:
Post a Comment