iphone - NSTimeInterval of today with time zero (midnight) -


how can calculate nstimeinterval of today hour minute , seconds zero?

i know nstimeinterval of today it's this:

nstimeinterval  today = [[nsdate date] timeintervalsince1970]; 

but how can reset time?

nsdate *currentdate = [nsdate date]; nsdatecomponents *currentdatecomponents = [calendar components:nshourcalendarunit | nsminutecalendarunit | nssecondcalendarunit fromdate:currentdate]; nsdatecomponents *currentdatetomidnight = [[nsdatecomponents alloc] init]; [currentdatetomidnight sethour:-[currentdatecomponents hour]]; [currentdatetomidnight setminute:-[currentdatecomponents minute]]; [currentdatetomidnight setsecond:-[currentdatecomponents second]]; nsdate *midnight = [calendar datebyaddingcomponents:currentdatetomidnight todate:currentdate options:0]; nstimeinterval todaytimeinterval = [midnight timeintervalsince1970]; 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -