How to format Facebook/Twitter dates (from the JSON feed) in Objective-C

前端 未结 8 995
有刺的猬
有刺的猬 2020-12-13 02:39

For my iPhone application...

I am looking for a way to format the Facebook created_time JSON property value.

\"created_time\": \"2010-12-0

8条回答
  •  春和景丽
    2020-12-13 03:20

    NSString *yourInputFBdate = @"2010-12-02T20:12:06+0000";
    NSString *fbDate = [yourInputFBdate stringByReplacingOccurrencesOfString:@"T" withString:@" "];
    fbDate = [fbDate stringByReplacingOccurrencesOfString:@"+" withString:@" +"];
    NSDate *date = [[NSDate alloc] initWithString:fbDate];
    
    /// do something with date ...
    
    [date release];
    

提交回复
热议问题