Skip to content

First day and last day in a month not behaving like in the browser. (Date object) #9333

@DimiTech

Description

@DimiTech
  • Version: v6.3.0
  • Platform: Windows 7 (64bit)
  • Subsystem: Node Core Runtime - Date object.

This is the code I use to get the first day and the last day of the month in the browser:

var firstDay = new Date((new Date()).getFullYear(), (new Date()).getMonth(), 1);
var lastDay  = new Date((new Date()).getFullYear(), (new Date()).getMonth() + 1, 0);
console.log(firstDay);
console.log(lastDay);

The browser gives the following (correct) results:
Sat Oct 01 2016 00:00:00 GMT+0200 (Central Europe Daylight Time)
Mon Oct 31 2016 00:00:00 GMT+0100 (Central Europe Standard Time)

Yet the Node runtime gives these results:
2016-09-30T22:00:00.000Z
2016-10-30T23:00:00.000Z

Disregarding the formatting, the numerical values for month and day aren't what they are when the same code is executed in the browser.

Has anyone else noticed this?
Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionIssues that look for answers.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions