1. Get today
/*! * @brief Get today * //1. Get accurate events for the current system (+ 8 hours) nsdate *date = [NSDate date];//Get Time object nstimezone *zone = [N Stimezone Systemtimezone]; Get the time zone of the system nstimeinterval time = [Zone secondsfromgmtfordate:date];//returns the difference between the current and system GMT in seconds nsdate *datenow = [Date datebyaddingtimeinterval:time];//and then add the bad time, is the current system accurate time
2. Get Yesterday and tomorrow
/*! * @brief get yesterday and tomorrow * * nstimeinterval secondsperday = * NSDate *date = [[NSDate alloc] initwithtimeintervalsincenow:-secondsperday]; Nstimezone *zone = [Nstimezone systemtimezone]; Get the time zone of the system nstimeinterval time = [Zone secondsfromgmtfordate:date];//returns the difference between the current and system GMT in seconds //Yesterday NSDate *yesterday = [date datebyaddingtimeinterval:time]; Tomorrow nsdate *tomorrow = [[NSDate alloc] initwithtimeintervalsincenow:secondsperday];
3. Time Format
/*! * @brief Time format * / nsdate *date = [NSDate date];//Get Time object nsdateformatter *formatter = [[ NSDateFormatter alloc] init]; [ForMatter setdateformat:@ "Hh-mm-ss yyyy-mm-dd"]; NSString *datestr = [ForMatter stringfromdate:date];
Acquisition time can also be nscalendar with the system.
Get time and formatting--today, yesterday and tomorrow