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

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

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

Using SpinKit-ObjC

I was looking to create a custom activity indicator, but adding additional time to a project was not possible. I found this cool project SpinKit-ObjC that provides ready made indicators.

Below is a demo of a few of them I checked out.

https://github.com/raymondjavaxx/SpinKit-ObjC

© 2015 Aldo Lugo

Theme by Anders NorenUp ↑