IOS-Date Time difference (a certain day of the month of the year ...) )

Source: Internet
Author: User

first create a formatted object

nsdateformatter *dateformatter = [[nsdateformatter alloc] init];

[Dateformatter Setdateformat:@ "Yyyy-mm-dd HH:mm:ss"];

// then create a Date object

nsdate *date1 = [dateformatter datefromstring:@ "2014-12-20 00:00:00"];

nsdate *date = [nsdate date];

// Calculate time interval (units in seconds)

nstimeinterval Time = [date1 timeintervalsincedate:d ate];

// count days, hours, minutes, seconds

int days = ((int) time)/(3600*);

int hours = ((int) time)% (3600*)/3600;

int minutes = ((int) time)% (3600*)%3600/;

int seconds = ((int) time)% (3600*)%3600;

nsstring *datecontent = [[nsstring alloc] initwithformat:@ "Some day of a certain month in a certain year %i days %i hours %i minutes %i seconds ", days,hours,minutes,seconds];

//(%i can automatically convert input to decimal , and %d does not convert)

// Assign value display

UILabel *timelab = (UILabel *) [self. View viewwithtag:666666];

Timelab. text = datecontent;

NSLog(@ "%@", datecontent);

Report:

Draw Heart 1:

#include <stdio.h>
int main () {
for (float y=1.5f;y>-1.5f;y-=0.1f) {
for (float x=-1.5f;x<1.5f;x+=0.05f) {
float a= x*x+y*y-1;
Putchar (a*a*a-x*x*y*y*y<=0.0f? ') *‘:‘‘);}
}
}

Draw Heart 2:

IOS-Date Time difference (a certain day of the month of the year ...) )

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.