title: Resolving Moment.js Deprecation Warning in Angular App
body: <p>I am getting an warning for the following code, using moment.js, in my Angular app:</p>
  
  <pre><code>moment(value).add(6, 'hours').format("MM/DD/YYYY");
  </code></pre>
  
  <p>The warning/error printing to the console is:</p>
  
  <blockquote>
    <p>moment.js:293 Deprecation warning: value provided is not in a
    recognized RFC2822 or ISO format. moment construction falls back to js
    Date(), which is not reliable across all browsers and versions. Non
    RFC2822/ISO date formats are discouraged and will be removed in an
    upcoming major release. Please refer to
    <a href="http://momentjs.com/guides/#/warnings/js-date/" rel="nofollow noreferrer">http://momentjs.com/guides/#/warnings/js-date/</a> for more info.
    Arguments:  [0] _isAMomentObject: true, _isUTC: false, _useUTC: false,
    _l: undefined, _i: Apr 10, 2007, 10:00:00 PM, _f: undefined, _strict: undefined, _locale: [object Object]</p>
  </blockquote>
  
  <p>I have looked at the documentation page linked in the warning, but it's still unclear to me what I need to change to get rid of the deprecation warning. I tried, for instance, adding an empty array as a second argument:</p>
  
  <pre><code>moment(value, []).add(6, 'hours').format("MM/DD/YYYY");
  </code></pre>
  
  <p>...but while that gets rids of the error, I get "invalid date" printed in my view, instead of the actual date. How do I need to adjust the syntax here to get rid of the warning?</p>
  
  <p>UPDATE: The value being provided is a UTC value that has been transformed using the Angular date pipe. So I am passing through two pipes: first the Angular date pipe, and then this custom pipe using moment. the full pipe code looks like this:</p>
  
  <pre><code>import { Pipe, PipeTransform } from '@angular/core';
  const moment = require('moment');
  
  @Pipe({name: 'timeZoneSync'})
  export class TimeZoneSyncPipe implements PipeTransform {
  
      constructor() { }
  
      transform(value) {
          if (value) {
              return moment(value).add(6, 'hours').format("MM/DD/YYYY");
          }
      }
  }
  </code></pre>
  
  <p>And in my view I am using the two pipes like this:</p>
  
  <pre><code>  &lt;input class="app-input" [ngModel]="client.dob | timeZoneSync | date:'medium'"
                                  (ngModelChange)="client.dob=$event" name="inputField" type="text" /&gt; 
  </code></pre>