Sort with moment.js: Deprecation warning: value provided is not in a recognized RFC2822 or ISO format

后端 未结 2 1129
南旧
南旧 2020-12-11 19:01

I parse dates I get from an API with Moment, and I need to sort the array when I\'m done collecting the data. I currently have this:

myobject.name = name;
my         


        
2条回答
  •  Happy的楠姐
    2020-12-11 19:45

    Based on the link to the momentjs docs in the warning, browsers may be unreliable or inconsistent in parsing the format you're providing "DD/MM/YYYY". If you need to keep this format, one solution would be to provide the format when converting the string back to a moment object when calculating the diff. So you could do return moment.utc(left.timeStamp, 'DD/MM/YYYY').diff(moment.utc(right.timeStamp, 'DD/MM/YYYY'))

提交回复
热议问题