IOS on large scale website shopping from the end of the event the remaining time countdown code

  • 2020-06-23 02:02:07
  • OfStack

In 2016 7 night panic buying 7 night base price straight down, full 268 minus 50! The full 468 100! Big shop from 49 yuan! Meet on Valentine's Day! American, Japanese and Japanese makeup perfume, 2 discount seconds to kill hot style! Absolutely authentic! A true expression of love! Flash sales and other activities are available. So the question is, how does this work based on code? Don't worry, the following effect brought to you about the large-scale website shopping, from the end of the event, the remaining time countdown core code, 1 to see it.

The key code is as follows:


/**
*  The countdown 
*
* @param endTime  The timestamp of the cut-off 
*
* @return  Return the remaining time 
*/
- (NSString*)remainingTimeMethodAction:(long long)endTime
{
// Get the current time 
NSDate *nowData = [NSDate date];
NSDate *endData=[NSDate dateWithTimeIntervalSince1970:endTime];
NSCalendar* chineseClendar = [ [ NSCalendar alloc ] initWithCalendarIdentifier:NSGregorianCalendar ];
NSUInteger unitFlags =
NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit | NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit;
NSDateComponents *cps = [chineseClendar components:unitFlags fromDate:nowData toDate: endData options:0];
NSInteger Hour = [cps hour];
NSInteger Min = [cps minute];
NSInteger Sec = [cps second];
NSInteger Day = [cps day];
NSInteger Mon = [cps month];
NSInteger Year = [cps year];
NSLog( @" From Now to %@, diff: Years: %d Months: %d, Days; %d, Hours: %d, Mins:%d, sec:%d",
[nowData description], Year, Mon, Day, Hour, Min,Sec );
NSString *countdown = [NSString stringWithFormat:@" And then there were : %zi day  %zi hours  %zi minutes  %zi seconds  ", Day,Hour, Min, Sec];
if (Sec<0) {
countdown=[NSString stringWithFormat:@" End of the activity / Start to snap up "];
}
return countdown;
}

The above code is IOS on the large-scale website shopping, from the end of the event, the remaining time countdown implementation code, code is relatively simple, we add and modify the appropriate according to the needs of the code, if found any questions during the reference process welcome to leave a message, this site will reply to you in a timely manner!


Related articles: