1 //1. Time Format2NSDateFormatter *_dateformatter =[[NSDateFormatter alloc] init];3[_dateformatter Setdateformat:@"yyyy mm month dd day hh hours mm min ss sec"];4 5 //2. Get the system time6NSString *date =[_dateformatter stringfromdate:[nsdate Date]];7 8 //3.NSDate conversion to timestamp9Nstimeinterval a=[Date timeIntervalSince1970];Ten One //4. Timestamp converted to NSDate ANSDate *stampdate =[NSDate Datewithtimeintervalsince1970:timeinter]; - - //4.NSDate conversion to NSString thensstring* datestring =[_dateformatter stringfromdate:date]; - - //5. Incoming time difference, reset format - //Incoming time difference, conversion format +-(NSString *) Timewithmessagestring: (nstimeinterval) Timeinter - { + A intmonth = Timeinter/(3600* -* -); at intDay = Timeinter/(3600* -); - inthour = Timeinter/3600; - intminute = Timeinter/ -; - - intday_process = Day-month * -; - inthour_process = Hour-day * -; in intminute_process = Minute-hour * -; - intMiao_process = timeinter-minute* -; to +NSString *timedate =Nil; - if(Day = =0) { theTimedate = [NSString stringWithFormat:@"%d hours%d minutes%d seconds", hour_process,minute_process,miao_process]; * if(Hour = =0) { $Timedate = [NSString stringWithFormat:@"%d minutes%d seconds", minute_process,miao_process];Panax Notoginseng if(Hour = =0) { -Timedate = [NSString stringWithFormat:@"%d seconds", miao_process]; the } + } A}Else{ theTimedate = [NSString stringWithFormat:@"%d days%d hours%d minutes%d seconds", day_process,hour_process,minute_process,miao_process]; + } - $ $Timedate = [NSString stringWithFormat:@"Limited Time Offer:%@ left", timedate]; - returntimedate; -}
Some conversions of ios--time Nsdate,nstimeinterval