Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
935 views
in Technique[技术] by (71.8m points)

ios - NSDate time converting from 12hr to 24 hr format

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
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;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...