title: How to insert and center text in Google Docs with script
body: <p>I want to make a script that inserts text like this at the end of my document:</p>
  
  <pre><code>                            February 18, 2015
                                    Title
     Entry
  </code></pre>
  
  <p>Where the first two lines are centered and the last line is indented with a tab. </p>
  
  <p>This is what I have so far:</p>
  
  <pre><code>  function addJournalTemplate(){
    var currDate = new Date();
    var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
    var dateString = months[currDate.getMonth()] + ' ' + (currDate.getDate() &lt; 10 ? '0' + currDate.getDate() : currDate.getDate()) + ', ' + currDate.getYear(); 
    var doc = DocumentApp.getActiveDocument();
    var dateText = doc.getBody().editAsText().appendText(dateString);
  
    var title = doc.getBody().insertParagraph(1, 'Title');
    title.setAlignment(DocumentApp.HorizontalAlignment.CENTER);
  }
  </code></pre>
  
  <p>And that code doesn't work at all. I am lost and have been searching developers.google.com for about an hour now. </p>
  
  <p>How can I do this?</p>