使用的东西:
self.lblTheDate.text = [NSDateFormatter localizedStringFromDate:[self.item valueForKey:@"MyDate"] dateStyle:NSDateFormatterMediumStyle timeStyle:NSDateFormatterNoStyle]
有该日期&时间风格的各种选项:
NSDateFormatterNoStyle : Specifies no style,
NSDateFormatterShortStyle : Specifies a short style, typically numeric only, such as “11/23/37” or “3:30pm”,
NSDateFormatterMediumStyle : Specifies a medium style, typically with abbreviated text, such as “Nov 23, 1937”,
NSDateFormatterLongStyle : Specifies a long style, typically with full text, such as “November 23, 1937” or “3:30:32pm”,
NSDateFormatterFullStyle : Specifies a full style with complete details, such as “Tuesday, April 12, 1952 AD” or “3:30:42pm PST”
请注意,这些日期和时间风格的格式是不准确因为它们依赖于语言环境,用户首选项设置和操作系统版本。
类参考: NSDateFormatter
感谢,这工作 – Joe24