admin管理员组文章数量:1404922
I am having a problem when using this library with vue.js
When I try to pass date in a table, I get this warning:
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 uping major release. Please refer to / for more info.
This is my code:
<small>{{ item.created_at | moment("from", "now", true) }}</small>
And this is how my codes without any filtering:
2021-10-11 11:17:03
I have tried this:
<small>{{ [item.created_at,"YYYY-MM-DD, h:mm:ss a"] | moment("from", "now", true) }}</small>
But now get this:
app.js Could not build a valid `moment` object from input.
Any idea how to fix this warning in vue js please?
Thank you
I am having a problem when using this library with vue.js https://www.npmjs./package/vue-moment
When I try to pass date in a table, I get this warning:
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 uping major release. Please refer to http://momentjs./guides/#/warnings/js-date/ for more info.
This is my code:
<small>{{ item.created_at | moment("from", "now", true) }}</small>
And this is how my codes without any filtering:
2021-10-11 11:17:03
I have tried this:
<small>{{ [item.created_at,"YYYY-MM-DD, h:mm:ss a"] | moment("from", "now", true) }}</small>
But now get this:
app.js Could not build a valid `moment` object from input.
Any idea how to fix this warning in vue js please?
Thank you
Share Improve this question edited Oct 11, 2021 at 12:51 mplungjan 179k28 gold badges182 silver badges240 bronze badges asked Oct 11, 2021 at 12:49 BennyBenny 4601 gold badge8 silver badges19 bronze badges 1-
Would that not be
moment().fromNow()
? – mplungjan Commented Oct 11, 2021 at 12:52
1 Answer
Reset to default 3Both of your approaches, as you warning tells you, do mismatch RFC2822/ISO8601.
RFC2822 would look like this:
01 Jun 2020 14:11:32 -0700
ISO8601 would look like this:
2021-10-10T22:00:00.000Z
If you need to get the date format of vue-moment
into ISO8601 format, you can do this in a short function like this:
showNewDate(date) {
return new Date(Date.parse(date))
}
If you pass 2021-10-11 11:17:03
to this function it will give you 2021-10-11T09:17:03.000Z
which is the date +- your timezone, in my example case minus two hours.
本文标签: javascriptValue provided is not in a recognized RFC2822 or ISO formatVue jsStack Overflow
版权声明:本文标题:javascript - Value provided is not in a recognized RFC2822 or ISO format - Vue js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744873835a2629796.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论