new Date(2015,2,30) and new Date(‘2015-2-30’)

You’re calling the Date constructor with different types of parameters :

  • in the first case you’re providing integers which it uses to populate its fields (the first three being the year, the month and the day of the month) ; note that the monthes are 0-indexed : a value of 1 in that field will correspond to February rather than January

  • in the second case you’re providing a String which will be parsed as if passed to Date.parse, that is as an ISO 8601 Extended Format date (YYYY‐MM‐DDTHH:mm:ss.sssZ)

Leave a Comment