Programming/JavaScript

[JavaScript] moment.js ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ / Deprecation warning: value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date().. ์˜ค๋ฅ˜

yuri lee 2023. 1. 7. 15:31
๋ฐ˜์‘ํ˜•

Intro

moment.js ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋‚ ์งœ ๊ฐ์ฒด๋ฅผ ๋‹ค๋ฃจ๋˜ ๋„์ค‘ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค. 

 

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 http://momentjs.com/guides/#/warnings/js-date/for more info.

 

Why?

๊ตฌ๊ธ€๋ง์„ ํ•ด๋ณด๋‹ˆ, ํ•ด๋‹น ์—๋Ÿฌ๋Š” moment ํ•จ์ˆ˜์—์„œ ์ง€์›ํ•˜์ง€ ์•Š๋Š” ํ˜•์‹์˜ ๊ฐ’์„ ์ž…๋ ฅํ–ˆ์„ ๋•Œ ๋ฐœ์ƒํ•œ๋‹ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. 

https://stackoverflow.com/questions/17987647/moment-js-transform-to-date-object

 

How to solve the problem

์œ„ stackoverflow ํŽ˜์ด์ง€์— ์—ฌ๋Ÿฌ ๋‹ต๋ณ€์ด ๋‹ฌ๋ ธ๋Š”๋ฐ์š”, ๊ทธ ์ค‘์—์„œ

moment().toDate();

์œ„ ์ฝ”๋“œ๋ฅผ ํ™œ์šฉํ•˜์—ฌ ๋‚ ์งœ ํ˜•์‹์„ ๋ฐ”๊ฟ”์ฃผ๋‹ˆ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. 

๋ฐ˜์‘ํ˜•