admin管理员组文章数量:1357646
I got the following input Wed, 08 Feb 2017 10:09:19 GMT
form server.
I've been trying to parse this string with momentjs but couldn't find format that will parse the GMT right.
and if i'm not putting format at all then i got warning value provided is not in a recognized ISO format. moment construction falls back to js Date()
Thanks!
I got the following input Wed, 08 Feb 2017 10:09:19 GMT
form server.
I've been trying to parse this string with momentjs but couldn't find format that will parse the GMT right.
and if i'm not putting format at all then i got warning value provided is not in a recognized ISO format. moment construction falls back to js Date()
Thanks!
Share Improve this question asked Feb 8, 2017 at 10:07 DimkinDimkin 7003 gold badges10 silver badges23 bronze badges 1- Check this stackoverflow./questions/32355297/… – kawadhiya21 Commented Feb 8, 2017 at 10:09
1 Answer
Reset to default 6Simply pass format
paramter to moment constructor:
var m = moment('Wed, 08 Feb 2017 10:09:19 GMT', 'ddd, DD MMM YYYY HH:mm:ss'); // Parse string in local time
console.log(m.format());
var mUtc = moment.utc('Wed, 08 Feb 2017 10:09:19 GMT', 'ddd, DD MMM YYYY HH:mm:ss'); // Parse string in UTC time
console.log(mUtc.format());
<script src="https://cdnjs.cloudflare./ajax/libs/moment.js/2.17.1/moment.min.js"></script>
Note that by default moment parses and displays in local time, if you need UTC see moment.utc
. If you need with multiple timezone use moment-timezone.
本文标签: javascriptParsing GMT date string with momentStack Overflow
版权声明:本文标题:javascript - Parsing GMT date string with moment - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744063521a2584565.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论