javascript date.getluceAr()的表现与date.getyear()相同



我正在尝试使用JavaScript获得这一年。我实例化了一个新日期()。我能够毫无疑问地获得一个月和日期。这一年无法正常工作。我正在使用getlasear(),因为所有文档和评论都对,而不是getyear(),但是,我得到117而不是2017年。控制台,如果我运行'(new date())。

如果我在控制台中声明任务函数,然后实例化新任务对象,则一切正常。任务对象的年度财产将为2017年。

我在做什么错?

function Task(task) {
  var d = new Date();
  this.task = task;
  this.date = d.getDate();
  this.month = d.getMonth();
  this.year = d.getFullYear()
  this.complete = false;
}
var task = new Task("task one");
['date', 'month', 'year'].forEach(function(p) {
  console.log(p + ' is ' + task[p]);
});
// date is 28
// month is 8
// year is 117

我正在使用不正确的JS文件。我使用getlyear()更新的文件不是正在运行的文件。正在运行的一个是使用getYear()。

最新更新