I have a collection of activities and MongoDB. Activities also have a date. I'm trying to dynamically build a table with all activities saved in my collection. Therefor I want to change the format of the date with moment.js right before I send the array of JSON objects to my jade file.
I tried to make a new results array and send this one over to my jade file.
    router.get('/', function(req, res, next) {
      activitiesController.getActivities(function(results) {
        if(!results) {
          results = [];
        }
        for(var key in results) {
          results[key].date = moment(results[key].date).format('ddd, hA');
        }
        res.render('index', {
          activities: results
        })
      });
    });
This is how the results array looks:
[{
    "_id" : ObjectId("56fe2c0d7afcafa412ae19c2"),
    "title" : "Fitnessstudios",
    "category" : "Sport",
    "time" : 2,
    "date" : ISODate("2016-03-30T00:00:00.000Z"),
    "__v" : 0
}]
 
     
    