IOS e-commerce shopping cart countdown time calculation

Source: Internet
Author: User

/** * Countdown * * @param endTime timestamp * * @return return time remaining */-(nsstring*) Remainingtimemethodaction: (Long Long) endtime{//        Get current time NSDate *nowdata = [NSDate Date];        Convert timestamp to date format nsdate *enddata=[nsdate datewithtimeintervalsince1970:endtime]; Create a Calendar object nscalendar* Chineseclendar = [[Nscalendar alloc] Initwithcalendaridentifier:nscalendaridentifiergregorian]        ; Set cell identity hour minute second day month year Nsuinteger unitflags = Nscalendarunithour | Nscalendarunitminute | Nscalendarunitsecond | Nscalendarunitday | Nscalendarunitmonth |        Nscalendarunityear;  Give the start time and end time to get the data for the identity of the unit 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 today to%@, Diff:years:%ld Months:%ld, Days;%ld, Hours:%ld, mins:%LD, Sec:%ld ", [nowdata description], year, Mon, Day, Hour, Min, sec);    NSString *countdown = [NSString stringwithformat:@ "still left:%zi days%zi hours%zi minutes%zi seconds", Day,hour, Min, Sec];    if (sec<0) {countdown=[nsstring stringwithformat:@ "activity end/start snapping"]; } return countdown;}  

IOS e-commerce shopping cart countdown time calculation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.