Last active
January 1, 2016 23:29
-
-
Save alex-zige/8216563 to your computer and use it in GitHub Desktop.
Rails standard time to object-c NSdate or vice versa
This file contains 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
//Rails time to NSdate | |
NSDateFormatter *df = [[NSDateFormatter alloc] init]; | |
[df setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZZ"]; | |
NSDate *date = [df dateFromString:@"2013-04-07T21:19:14Z"]; | |
//NSDate to String | |
NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; | |
[formatter setDateFormat:@"MM/dd/yyyy HH:mm a"]; | |
//Optionally for time zone converstions | |
[formatter setTimeZone:[NSTimeZone timeZoneWithName:@"Pacific/Auckland"]]; | |
NSString *meeting_date = [formatter stringFromDate:meeting.meeting_date]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment