-2
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

Gullu
  • 3,477
  • 7
  • 43
  • 70
  • 1
    I'm going to stick my neck out and say that I don't believe this is the line of code that is generating the warning. As I understand it, you can only get the deprecation warning when passing a single string into `moment(...)` but the line of code you show above passes two arguments. – Luke Woodward Oct 18 '18 at 20:50

1 Answers1

0

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

puddi
  • 811
  • 4
  • 10
  • 1
    The line that was throwing the warning was actually like moment('12/25/2018') and not the one I thought it was which I mentioned in my question. That fixed it. Thanks – Gullu Oct 18 '18 at 20:52