1NSDate *date = [NSDate Date];//Get current Time2Nstimezone *zone = [Nstimezone systemtimezone];//Modify Time Zone3Nsinteger interval1 = [zone secondsfromgmtfordate:date];//Modify Time Zone4_localdate1 = [date Datebyaddingtimeinterval:interval1];//Modify Time Zone5NSLog (@"~~~~~~~~~~~~~ Today%@\n", _localdate1);6 7 8Nscalendar *calendar =[Nscalendar Currentcalendar];9nsdatecomponents *comp = [Calendar Components:nsyearcalendarunit | Nsmonthcalendarunit | Nsdaycalendarunit | Nsweekdaycalendarunit |Nsdaycalendarunit fromdate:_localdate1];Ten One //get current Month day ANsinteger year =[comp year]; -Nsinteger month =[Comp month]; -Nsinteger Day =[Comp Day]; the -nsdatecomponents * Components =[[Nsdatecomponents alloc]init]; - - //setting + [Components setyear:year]; - [Components Setmonth:month]; + [Components Setday:day]; A[Components Sethour: -]; at[Components Setminute: +]; - -Nscalendar *current =[Nscalendar Currentcalendar]; - -NSDate *setdate1 =[Current datefromcomponents:components]; - //The default time zone is Greenwich 0 time zone, we are in the East 8 area inNstimezone *zone2 = [Nstimezone systemtimezone];//Modify Time Zone -Nsinteger Interval2 = [Zone2 secondsfromgmtfordate:setdate1];//Modify Time Zone to_localdate2 = [SetDate1 datebyaddingtimeinterval:interval2];//Modify Time Zone + -NSLog (@"-----------%@\n", _localdate2); the //_localdate1-_localdate2, the result of the default is the second, you can convert *Nsinteger lasttime = [_localdate2 timeintervalsincedate:_localdate1]/ -; $NSLog (@"!!!!!!!!!!!! %ld\n", lasttime);
Day will be added one more days, do not know what is the situation
Get current time, set time, and calculate travel value in iOS