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

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

Making Empty C++ Project: General exception (Exception from HRESULT:0x80131500) Visual Studio Community 2015 -

How to fix java warning for "The value of the local variable is not used " -