Created
October 7, 2015 14:14
-
-
Save hashmaparraylist/763f38b11a55cbccf2c9 to your computer and use it in GitHub Desktop.
convert utc to local
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
| NSTimeZone* sourceTimeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"]; | |
| NSTimeZone* destinationTimeZone = [NSTimeZone localTimeZone]; | |
| NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; | |
| [dateFormatter setDateFormat:formatter]; | |
| [dateFormatter setTimeZone:sourceTimeZone]; | |
| NSDate *rawDate = [dateFormatter dateFromString:dateTime]; | |
| NSDateFormatter *localFormatter = [[NSDateFormatter alloc] init]; | |
| [localFormatter setTimeZone:destinationTimeZone]; | |
| [localFormatter setDateStyle:NSDateFormatterMediumStyle]; | |
| [localFormatter setTimeStyle:NSDateFormatterShortStyle]; | |
| return [localFormatter stringFromDate:rawDate]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment