Created
December 7, 2017 16:39
-
-
Save aflansburg/f99ee70461706c62212e68d7b6e07419 to your computer and use it in GitHub Desktop.
Add a timestamp to a cell in Google Sheets (Gsheets)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addTimestamp(){ | |
var ss = SpreadsheetApp.getActiveSpreadsheet(); | |
var sheet = ss.getSheets()[0]; | |
var cell = sheet.getRange('A1'); | |
var d = new Date(); | |
d.setHours(d.getHours()); | |
var user = Session.getActiveUser().getUserLoginId(); | |
user = String(user); | |
// cosmetic: this just removes the email domain from the user info | |
user = user.replace('@gmail.com', ''); | |
cell.setValue('Last updated: ' + d.toLocaleString() + ' by ' + user); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment