Life & Technology

Handful lessons in different areas of technology and life in general.

Monthly Archives: December 2010

iPhone: NSDate as Double and vice versa

If you’re parsing JSON result from a webservice that returns date as double value and you like to display the human readable date formatted NSDate, one possible method we could achieve this is by using NSDate dateWithTimeIntervalSince1970. As our example below, we like to convert the value of “exp” from Double and vice versa.


Parsing this in Objective-C is pretty straightforward and you only need NSDate class for the conversion.


And when we run it via SImulator, we can see similar result here:

iPhone Simulator

Simple and useful.

Reference: NSDate Class Reference