ios - String to time format in objective c -
here code,
nsstring *starttime =@"05:00:00";
it in string format ,i want in hh:mm:ss
,please how do, did, shows 1999-12-31 23:30:33
nsdateformatter *dateformat = [[nsdateformatter alloc] init]; [dateformat setdateformat:@"hh:mm:ss"]; nsdate *starttime = [dateformat datefromstring:starttime];
just add time zone so:
nsstring *starttime =@"5:00:00"; nsdateformatter *dateformat = [[nsdateformatter alloc] init]; [dateformat setdateformat:@"hh:mm:ss"]; [dateformat settimezone: [nstimezone timezonewithname:@"utc"]]; nsdate *starttime = [dateformat datefromstring:starttime];
which convert : 2000-01-01 05:00:00 utc
Comments
Post a Comment