我有这个时间字符串如何在JavaScript中解析日期时间字符串的日期部分?
Tue, 20 Oct 2015 17:14:47 +0200
我需要从这个返回的日期部分。换句话说,从它得到date
,month
和year
。
目前我所做的:
pub_date = new Date("Tue, 20 Oct 2015 17:14:47 +0200")
day = pub_date.getDate()
month = pub_date.getMonth()
year = pub_date.getYear()
只有day
得到正确返回。 month
和year
返回错误结果。什么会更正确?
什么是不正确的结果你看到了吗? – AtheistP3ace
当有疑问时...阅读手册https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date – charlietfl