Get Updates By E-mail 

Article Written By:
Johann Dowa

Library For Working With Dates Providing Helpers For Formatting, Parsing, Validation And Manipulation

  •  
  •  
  •  
  •  
  •  

I’ve mentioned a number of helper libraries for working with NSDate such as this library for grabbing locale aware dates and times and a handy collection of NSFormatter classes including helpers for showing the time between two NSDate objects.

Here’s an excellent library for working with dates called NSMoment from Yannick Loriot.

NSMoment is inspired by the Moment.js library and provides an extensive number of methods for formatting, parsing, validating and manipulating dates.

Here’s a few examples from the readme showing off some of the included formatting, localization, and calculation methods in the library:

NSLog(@"%@", [moment format:@"MMMM dd yyyy, h:mm:ss a"]); // October 27 2013, 10:49:48 AM

NSMoment *moment1 = [NSMoment momentWithDateAsString:@"20111031"];
NSLog(@"%@", [moment1 fromNow]); // 2 years ago

NSMoment *french = [[NSMoment now] addAmountOfTime:-3 forUnitKey:@"s"];
[french setLocale:[NSLocale localeWithLocaleIdentifier:@"fr_FR"]];
NSLog(@"%@", [french fromNow]); // il y a quelques secondes

You can find NSMoment on Github here.

A very useful library for working with dates.


  •  
  •  
  •  
  •  
  •  

Submit A Resource

Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?

You can submit the url here.

The resources we feel will appeal to our readers the most will be posted on the front page.

Comments