title: How to format a moment date with angularjs
body: <p>I am using angularjs with moment.</p>
  
  <p>I need format a moment date.</p>
  
  <p>Moment is installed correctly and working.</p>
  
  <p>I have a variable mydate showing below.</p>
  
  <p>My code is:</p>
  
  <pre><code>$scope.mylabel= moment(date).format('YYYY-MM-DD');
  </code></pre>
  
  <p>After that, I get $scope.mylabel= 'invalid date'</p>
  
  <p>What am I doing wrong?</p>
  
  <p>mydate is:</p>
  
  <pre><code>{date: r, mdp: {…}, selectable: true, $$hashKey: "object:156"}
  $$hashKey:
  "object:156"
  date:
  r
  _d:Fri Nov 10 2017 00:00:00 GMT-0200 (Horário brasileiro de verão) {}
  _isAMomentObject:true
  _isUTC:false
  _isValid:true
  </code></pre>
  
  <p><strong>The complete code is:</strong></p>
  
  <p>I am using the next widget:</p>
  
  <pre><code>https://github.com/arca-computing/MultipleDatePicker
  </code></pre>
  
  <p>//markup</p>
  
  <pre><code>&lt;div class="col-sm-3"&gt;
      &lt;multiple-date-picker  calendar-id="'myId2'" ng-model="myDate" 
      day-click="oneDaySelectionOnly"&gt;&lt;/multiple-date-picker&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>//controller</p>
  
  <pre><code>angular.module("clinang")
  .controller('agendaGeralController'......
   $scope.myDate = [];
   $scope.myDate.push(moment());
   $scope.oneDaySelectionOnly = function (event, date) {
      $scope.mylabel= moment(date).format('YYYY-MM-DD')
      //I also tried date.format('YYYY-MM-DD') and both result in "invalid date")
      $scope.myDate.length = 0;
  };
  ]);
  </code></pre>