使用的東西:
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