Skip to content

Instantly share code, notes, and snippets.

@neiraza
Created February 17, 2014 11:51
Show Gist options
  • Save neiraza/9049253 to your computer and use it in GitHub Desktop.
Save neiraza/9049253 to your computer and use it in GitHub Desktop.
Twitterのcreated_atを素敵なNSStringにした ref: http://qiita.com/neiraza/items/ea78899d617e523b5e2d
Mon Feb 17 11:36:30 +0000 2014
- (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