NSDate time converting from 12hr to 24 hr format

后端 未结 7 528
抹茶落季
抹茶落季 2020-12-19 22:22

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 P

7条回答
  •  醉梦人生
    2020-12-19 23:03

    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    dateformatter.dateFormat = @"hh:mm a";
    NSDate *date = [dateformatter dateFromString:departTime];
    dateformatter.dateFormat = @"HH:mm";
    NSString *time24 = [dateformatter stringFromDate:date];
    departTimelbl.text=time24;
    

提交回复
热议问题