NSDate time converting from 12hr to 24 hr format

2020-02-12 14:29发布

hi i have problem while converting Date Formats... the date time is in the Format 12 hour Format like 12/9/2010 4:00:00 PM (Month/date/year Hour:Min:sec Pm) i need to Convert it into 24 hour format like 12/9/2010 16:00:00
Can any one Help me please.... Thx in advance

7条回答
劳资没心,怎么记你
2楼-- · 2020-02-12 15:12
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateFormat = @"HH:mm";
NSDate *date = [dateFormatter dateFromString:@"15:15"];

dateFormatter.dateFormat = @"hh:mm a";
NSString *pmamDateString = [dateFormatter stringFromDate:date];
查看更多
登录 后发表回答