Instead of using getTime(), it's probably better to work with Date objects directly. This way your data will be sent across the wire and stored tagged as the BSON datetime type rather than an integer type. You can insert and retrieve the current date like this:
> db.foo.insert({time: new Date});
> db.foo.findOne();
{
"_id" : ObjectId("523b182d42214dac3729419f"),
"time" : ISODate("2013-09-19T15:28:45.175Z")
}
And here is how you could query for everyone who is between 20 and 30 years old:
var t1 = new Date();
var t2 = new Date();
t1.setYear(t1.getYear() - 30);
t2.setYear(t2.getYear() - 20);
db.people.find({
birth_date : {$gt: t1, $lt: t2}
});