Search code examples
nsdateformatterdate-conversion

Date Convert in to special Format in iphone


I get a date's parsed data in the form like as "2014-09-20 09:59:30" and I want to convert them into 20 SEP 2014. and print it into label. How can I convert them and print it into the label?


Solution

  • i got then Answer of my this Question so i poet here i got the Date in format like as "2014-09-20 09:59:30" From JSON Data and i want to show this Date in the Format like as 20 SEP 2014 then i got a Code for this is And if we want to convert it in to upper case then just write label.text string to uppercaseString.

    NSDateFormatter * dateFormatter = [[NSDateFormatter alloc]init];
    [dateFormatter setDateFormat:@"yyyy-MM-dd hh:mm:ss"];
    NSString *date=[dict valueForKey:@"post_date"];
    NSDate * dateNotFormatted = [dateFormatter dateFromString:date];
    [dateFormatter setDateFormat:@"d MMM YYYY"];
    NSString * dateFormatted = [dateFormatter stringFromDate:dateNotFormatted];
    cell.dateLabel.text=[dateFormatted uppercaseString];