Created
November 14, 2015 02:55
-
-
Save davidboy/19863932608dbb6d4a34 to your computer and use it in GitHub Desktop.
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 onEdit() { | |
var cell = SpreadsheetApp.getActiveSheet().getActiveCell(); | |
switch (cell.getColumn()) { | |
case 2: | |
insertTimestamp(cell, 'C'); | |
break; | |
case 4: | |
insertTimestamp(cell, 'E'); | |
break; | |
case 7: | |
insertTimestamp(cell, 'H'); | |
break; | |
case 9: | |
insertTimestamp(cell, 'J'); | |
break; | |
} | |
} | |
function insertTimestamp(modifiedCell, timestampColumn) { | |
var row = modifiedCell.getRow(); | |
var offset = "GMT-"+Math.floor((new Date()).getTimezoneOffset() / 60); | |
var time = Utilities.formatDate(new Date(), offset, "hh:mm a"); | |
SpreadsheetApp.getActiveSheet().getRange(timestampColumn + row.toString()).setValue(time); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment