node.js mongodb retrieve ISODate format

In mongodb the value of date is:

"date" : ISODate("2012-10-11T07:00:00Z")

In node with mongoose I retrieve the date and has the following value:

entry.date = 2012-10-11T07:00:00.000Z

So in my code I do the following:

var date = new Date(entry.date);
var format = date.getMonth() + '/' + date.getDate() + '/' + date.getFullYear();

I get the output:

9/11/2012

What is wrong with this?
I would have thought the output would be: 10/11/2012

I understand the month starts from 0-11 in Date. But since im taking it from a date format why would I have to minus 1 month from it.

Thanks

JavaScript Date.getMonth() is zero based, not one based.

The "date" variable is a Date, not a "date format" as you suspect (JavaScript has no such concept).

var dateStr = '2012-10-11T07:00:00.000Z';
var date = new Date(dateStr); // Thu Oct 11 2012 01:00:00 GMT-0600 (MDT)
date.getMonth(); // => 9 (October)

Try this instead:

var format = (date.getMonth()+1) + //...