ios - Storing date and time separately in NSDate -
so getting string containing date , time in format "2014-12-22t11:00:00+0500"
in order convert nsdate using
nsdateformatter* dateformatter = [[nsdateformatter alloc]init]; [dateformatter setdateformat:@"yyyy-mm-dd't'hh:mm:sszzz"]; nsdate* date = [dateformatter datefromstring:start_time]; [dateformatter setdateformat:@"yyyy-mm-dd"]; nsstring* temp = [dateformatter stringfromdate:date]; self.eventdate = [dateformatter datefromstring:temp]; nsdateformatter* timeformatter = [[nsdateformatter alloc]init]; [timeformatter setdateformat:@"hh:mm:ss"]; nsstring* temp2 = [timeformatter stringfromdate:date]; self.start_time = [timeformatter datefromstring:temp2];
now though conversion successful problem eventdate
has has time after date 00:00:00
. how can remove eventdate
contains date.
conversly start_time
has time of event has arbritrary reference date before that. how can remove have time in start_time
i have searched hard , fast haven't been able figure out problem. appreciated.
you cannot remove either date or time keep 1 component. if remember correctly nsdate object internally number of seconds relative fixed point in time. every nsdate contains full date , time information.
what want nsdatecomponents want nsdate object.
Comments
Post a Comment