ios - How to convert current date to a specific 24h format? -
i'd convert current date following 24h format:
2015-07-14t14:43:30,727
tried following:
nsdateformatter *dateformatter = [[nsdateformatter alloc] init]; [dateformatter setdateformat:@"yyyy-mm-dd't'hh:mm:ss,sss"]; nsstring *datestring = [dateformatter stringfromdate:[nsdate date]];
the problem doesn't work if 24-hour time turned off in phone's (iphone 6) settings (i.e. phone set 12h format).
what doing wrong?
try following code :
nsdateformatter *dateformat = [[nsdateformatter alloc] init]; [dateformat setdateformat:@"yyyy-mm-dd hh:mm:ss"];
hh means 24 hour format
hh means 12 hour format.
Comments
Post a Comment