Hong Van Vit
Hong Van Vit

Reputation: 2976

Get month function return wrong value

I used script to change from TIMESTAMP in Oracle from Json to dd/mm/yy, but the function getMonth of javascript return month fail. In example below, the Month is 3 but it return is 2. Why? Please help.

    var date = "/Date(1520996412000)/";
    var fullDate = new Date(date.match(/\d+/)[0] * 1);
    var twoDigitMonth = fullDate.getMonth() + "";
    console.log(fullDate);
    console.log(twoDigitMonth);

Upvotes: 0

Views: 150

Answers (2)

Perry2008084
Perry2008084

Reputation: 956

getMonth() method's return value:

An integer number, between 0 and 11, representing the month in the given date according to local time. 0 corresponds to January, 1 to February, and so on.

Upvotes: 1

Joseph M
Joseph M

Reputation: 141

The getMonth() method returns the month in the specified date according to local time, as a zero-based value (where zero indicates the first month of the year).

Upvotes: 4

Related Questions