tree em
tree em

Reputation: 21701

why I get display next month instead of current month

Why I see this page is in wrong month, it should init to show August instead of September , I am from cambodia

enter image description here http://react-day-picker.js.org/examples/months-initial

Upvotes: 1

Views: 287

Answers (2)

Ryo Shiina
Ryo Shiina

Reputation: 568

I've been looking around your site for a couple of minutes, and I noticed that the month number is capped at 11 (so December equals 11). That must be because of common code basics, where the first item of an array starts with an index of 0 (= January). Your timezone has nothing to do with the site so don't worry ! (tested from France)

Upvotes: 3

Tudor Ilisoi
Tudor Ilisoi

Reputation: 2944

From MDN docs: The argument month is 0-based. This means that January = 0 and December = 11.

var startOfYear =  new Date(2017,0)
console.log(startOfYear.toLocaleString())

Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date

Upvotes: 5

Related Questions