How can I easily access the MongoDB ObjectId date from within a templating engine?

At the moment using JavaScript I'm attaching a date to every single object similar to the following.

post.date = getTimestamp(post._id).toDateString();

I can then access 'date' from within my template. Is there a nicer way to extract the date?

I'm not sure if this will work in a template, but:

post._id.getTimestamp();

returns an ISODate.

http://mongodb.github.com/node-mongodb-native/api-bson-generated/objectid.html#gettimestamp

If _id is UUID, then first 8 bytes of it is timestamp. You may, fore example, extract date as follows:

var date = new Date( parseInt( post._id.substring(0,8), 16 ) * 1000 )