Created
January 11, 2013 01:01
-
-
Save desaiashu/4507119 to your computer and use it in GitHub Desktop.
Convert NSNumber representing epoch time to NSDate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Epoch time (or unix time) is the number of seconds since Jan 1st 1970 00:00:00 UTC | |
// To convert an NSNumber representing epoch time to an NSDate object: | |
NSNumber *epochTimeOfSomeEvent = [NSNumber numberWithDouble:1357865700]; | |
NSDate * dateOfThatSameEvent = [NSDate dateWithTimeIntervalSince1970:epochTimeOfSomeEvent]; | |
// You can then compare this NSDate to the current date to get useful information from it |
Passing a NSNumber to the dateWithTimeIntervalSince1970 is wrong.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Passing a NSNumber to the dateWithTimeIntervalSince1970 is wrong.