我正在尝试使用NSDateFormatter将NSString转换为2013-02-08T10:50:00.000到10:50 AM,无论我做什么,我似乎无法获得AM或让它与之合作超过12(2013-02-08T15:00:00.000)的任何想法?
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"HH-mm"];
NSString *datelocalformat= [dateFormatter stringFromDate:DepartTimeString];
答案 0 :(得分:0)
NSDate *today = [NSDate date];//get today's date
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateStyle:NSDateFormatterShortStyle];
NSString *dateString = [dateFormatter stringFromDate:today];
[dateFormatter release];
// Get time - display in 12HR
NSDateFormatter *timeFormatter = [[NSDateFormatter alloc] init];
[timeFormatter setTimeStyle:NSDateFormatterLongStyle];
NSString *timeString = [timeFormatter stringFromDate:today];
[timeFormatter release];