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' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -