MonthFebruary 2015

Friendly dates with MongoDB and Moment.js

I’m working on a project where any new comment posted gets tagged with a timestamp in milliseconds (local time). My issue was when I display the comments but I¬†want to compare the saved timestamp with the current time. I need to be able to still keep the saved timestamp and show a humanized version to the user.

Here is what I had to do. Works for my situation but perhaps there is a better solution. I used underscore.js. I iterated over the returned document and modified the timestamp property with the humanized version. Now instead of the user seeing something like 1123992032 they see “few minutes ago” depending on the current time.

IOS Resources


CocoaPods is the dependency manager for Cocoa projects. It has thousands of libraries and can help you scale your projects elegantly.

Cocoa Controls

Cocoa Controls lists custom controls and views for iOS and Mac OS X, helping you improve the quality of your Cocoa application with the least work possible.


NSHipster is a journal of the overlooked bits in Objective-C, Swift, and Cocoa. Updated weekly.

© 2018 Aldomatic

Theme by Anders NorenUp ↑