title: How to automatically add a timestamp in google spreadsheet
body: <p>I have a sheet in my Google spreadsheet that contains 5 cells, the first 3 contains only words while the last 2 contains time, specifically a timestamp. </p>
  
  <pre><code>cell 1 = data
  cell 2 = data
  cell 3 = data
  cell 4 = time start
  cell 5 = time ended
  </code></pre>
  
  <p>Now, what I want is when cell 1 is supplied with data, a timestamp will automatically appear in cell 4. And when cell 2 and cell 3 is supplied with data, a timestamp will be the new value for cell 5.</p>
  
  <p>My friend give me a code, that should pasted in Script editor:</p>
  
  <pre><code>function readRows() {
    var sheet = SpreadsheetApp.getActiveSheet();
    var rows = sheet.getDataRange();
    var numRows = rows.getNumRows();
    var values = rows.getValues();
  
  for (var i = 0; i &lt;= numRows - 1; i++) {
    var row = values[i];
    Logger.log(row);
   }
  };
  </code></pre>
  
  <p>And</p>
  
  <pre><code>function onOpen() {
   var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
   var entries = [{
   name : "Read Data",
   functionName : "readRows"
  }];
  spreadsheet.addMenu("Script Center Menu", entries);
  };
  function timestamp() {
  return new Date()
  }
  </code></pre>
  
  <p>and this code is pasted in <code>=IF(B6="","",timestamp(B6))</code>cell 4 and this one <code>=IF(D6="","",timestamp(C6&amp;B6))</code> is on cell 5. in his example tracker its working. But when i copied it to mine, the output in cell 4 and cell 5 is the Date today and not the time.</p>
  
  <p>can anyone help me? why does it output the date and not the time?</p>