Why the dates (month) isnt displaying correctly in the localhost?


#1

For example, if I specified '03' in the following code, it would appear to be April? It's as if every single one of my month's have been increased by one. Anyone else notice this? It's just been bothering me a lot.
$scope.products = [
{
name: 'The Book of Trees',
price: 19,
pubdate: new Date('2014', '03', '08'),
cover: 'img/the-book-of-trees.jpg',
likes: 0,
dislikes: 0
},


#2

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

I'd prefer starting from 1 too as months are associated with numbers starting from 1, unlike for example week-days.

Note that your numbers are coerced into number types (won't be treated as strings)


#3

@ionatan
@chipsurfer03240
I think his question was:
Why is it if you use

var aDate = new Date('2014', '03', '08');
console.log( aDate );
var bDate = new Date(2014,3,8);
console.log( bDate );

you get the output:

Mon, 07 Apr 2014 22:00:00 GMT
Mon, 07 Apr 2014 22:00:00 GMT

I cannot explain this.......


#4

The arguments are explained in MDN's doc for Date