NSDateFormatter, am I doing something wrong or is this a bug?

后端 未结 8 995
-上瘾入骨i
-上瘾入骨i 2020-11-30 06:18

I\'m trying to print out the date in a certain format:

NSDate *today = [[NSDate alloc] init];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]         


        
8条回答
  •  旧巷少年郎
    2020-11-30 07:17

    Using the code you posted on both the simulator and a phone with the 2.1 firmware and 24-hour time set to off, I never had an AM/PM appended to dateStr when I do:

    NSLog(@"%@", dateStr);
    

    Are you doing anything else with dateStr that you didn't post here? How are you checking the value?

    Follow up

    Try turning the am/pm setting on then off. I didn't have the problem either, until I did that. I am printing it out the same way you are.

    Okay, I see it when I do this also. It's gotta be a bug. I recommend you file a bug report and just check for and filter out the unwanted characters in the meantime.

提交回复
热议问题