title: Formatted dates in a Google Apps script
body: <p>I'm trying to get a spreadsheet with simple formatted dates when a form is submitted, but all dates, including the timestamp keep getting posted as "Dec 31 1969 2:00PM"... What am I doing wrong? ANY help would be greatly appreciated.</p>
  
  <pre class="lang-js prettyprint-override"><code>function formSubmitReply(e) {
    var sheet = SpreadsheetApp.getActiveSheet();
    var row = sheet.getActiveRange().getRowIndex();
    var lastRow = sheet.getLastRow();
    // Set the status of a new ticket to 'New'.
  
    sheet.getRange(lastRow, getColIndexByName("Status")).setValue("New");
  
    var ticketTime = sheet.getRange(row, getColIndexByName("Timestamp")).getValue();
  
    var subdate = Utilities.formatDate(new Date(ticketTime), "GMT-10", "EEE MM/dd/yyyy 'at' h:mm a");
    sheet.getRange(lastRow, getColIndexByName("Timestamp")).setValue(subdate);
  
    var sDate = sheet.getRange(row, getColIndexByName("Start Date")).getValue();
    var strtdate = Utilities.formatDate(new Date(sDate), "GMT-10", "EEE, MMM dd, yyyy");
    sheet.getRange(lastRow, getColIndexByName("Start Date")).setValue(strtdate);
  
    var sTime = sheet.getRange(row, getColIndexByName("Start Time")).getValue();
    var strttime = Utilities.formatDate(new Date(sTime), "GMT-10", "h:mm");
    //sheet.getRange(lastRow, getColIndexByName("Start Time")).setValue(strttime);
  
    var eDate = sheet.getRange(row, getColIndexByName("End Date")).getValue();
    var enddate = Utilities.formatDate(new Date(eDate), "GMT-10", "EEE, MMM dd, yyyy");
    sheet.getRange(lastRow, getColIndexByName("End Date")).setValue(enddate);
  
    var eTime = sheet.getRange(row, getColIndexByName("End Time")).getValue();
    var endtime = Utilities.formatDate(new Date(eTime), "GMT-10", "h:mm");
    //sheet.getRange(lastRow, getColIndexByName("End Time")).setValue(endtime);
  }
  </code></pre>