用时刻parsingGMTdatestring

我得到了以下inputWed, 08 Feb 2017 10:09:19 GMT格式服务器。 我一直试图parsing这个string与momentjs,但无法find将parsing格林尼治标准时间的格式。

如果我没有把格式的一切,那么我得到的警告value provided is not in a recognized ISO format. moment construction falls back to js Date() value provided is not in a recognized ISO format. moment construction falls back to js Date()

谢谢!

只需将formatparameter passing给构造函数即可:

 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.com/ajax/libs/moment.js/2.17.1/moment.min.js"></script>