Search code examples
javascriptangulartypescriptmomentjsangular-moment

momentjs deprecated warning not going away


somestringvar = moment(entry.expirationDate, "MM/DD/YYYY").format("MMM-DD-YYYY").toString();

The date is correctly converted to the format I need like Nov-11-2018 but I just cannot get rid of that infamous moment js deprecated warning. Tried many combinations. The warning I get is 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

Please advise how to get rid of this warning. I am using latest angular version and typescript code. Thanks


Solution

  • A simple way to get around is changing the moment constructor to moment(new Date(entry.expirationDate)).