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

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -