NSDateFormatter dateFromString

前端 未结 2 1591
暗喜
暗喜 2021-01-05 07:33

The string which comes from my data source is formatted like this:

2011-04-11 23:12:05

// dateString comes from my data          


        
2条回答
  •  执笔经年
    2021-01-05 07:37

    // set norwegian locale
        dateFormatter.locale=[[NSLocale alloc] initWithLocaleIdentifier:@"no_NO"];;
    
        dateFormatter.dateFormat=@"MMMM";
        NSString * monthString = [[dateFormatter stringFromDate:date] capitalizedString];
        NSLog(@"month: %@", monthString);
    

    This is a norwegian example. With your language it should be "se_SE"

提交回复
热议问题