Gabriel Piffer Gabriel Piffer - 4 months ago 74
Javascript Question

Add a timestamp programatically

I am trying to create a code to Google Spreadsheets . In VBA code it is very simple. My goal is, when a particular cell is filled , another cell displays the date and time of completion .


Function DateTime()
DateTime = NOW
End Function


Based on your most recent comment stating that you want to call a custom function from the Google Sheet frontend, all you will need in your Script Editor (backend) is:

function timeStamp() {
  return new Date();

You can then call that function from a formula in your Sheet, very similar to what you wrote already:

=IF( ISBLANK(A1), "", timeStamp() )