简体   繁体   English

使用矩将日期字符串转换为日期对象

[英]Convert date string to date object using moment

there is a situation which I need to convert a date string which consist a timezone abbrevation to a Moment object and parse it. 在某些情况下,我需要将包含时区缩写的日期字符串转换为Moment对象并进行解析。 How can I do this? 我怎样才能做到这一点? sample date is like below: 采样日期如下:

var dateString = "2015-01-14 06:57:47 ECT";

be aware that I need the timezone of this date, because Im going to do another conversion to another zone, so if we just consider the date we miss the accuracy. 请注意,我需要该日期的时区,因为我要进行另一次转换到另一个时区,所以如果我们仅考虑日期,则会错过准确性。

我不认为一时可以处理时区名称,您应该将ECT替换为偏移值,例如+0200

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM