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 -

Socket.connect doesn't throw exception in Android -

iphone - How do I keep MDScrollView from truncating my row headers and making my cells look bad? -