I tried following code in mongo 2.4.8 and found when you take difference between two dates it returns a result in millisecond,then wrote following function to get data in minutes. Here I have assumed you have two date fields in your document 'entered'(when user entered) and 'left'(when user left) and finally you calculate the difference in minutes and store 'timespent' in the same document
db.collectioName.find().forEach(function(d){
//you can use Math.ceil or Math.floor
d.timespent=Math.round((d.visited-d.left)/60000);
db.collectioName.save(d);
});
Hope it helps