Created
February 17, 2014 11:51
-
-
Save neiraza/9049253 to your computer and use it in GitHub Desktop.
Twitterのcreated_atを素敵なNSStringにした ref: http://qiita.com/neiraza/items/ea78899d617e523b5e2d
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
Mon Feb 17 11:36:30 +0000 2014 |
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
- (NSString *)createdAtToString:(NSString *)dateStr | |
{ | |
NSDateFormatter *inputFormat = [[NSDateFormatter alloc] init]; | |
[inputFormat setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]]; | |
[inputFormat setDateFormat:@"eee MMM dd HH:mm:ss ZZZZ yyyy"]; | |
NSDate *date = [inputFormat dateFromString:dateStr]; | |
NSDateFormatter *outputFormat = [[NSDateFormatter alloc] init]; | |
[outputFormat setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"ja_JP"]]; | |
[outputFormat setDateFormat:@"yyyy/MM/dd HH:mm:ss"]; | |
return [outputFormat stringFromDate:date]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment