Gets the current time based on Greenwich Mean time display
Time 8 hours UK Greenwich 7 HOURS
NSDate *date = [NSDate Date];
NSLog (@ "%@", date);
Nszone Calculating time zones
Get a time parameter based on the current time is seconds
NSDate *somedate = [NSDate datewithtimeintervalsincenow:3600];
NSLog (@ "%@", somedate);
Get a long time
NSDate *futuredate = [NSDate distantfuture];
NSLog (@ "%@", futuredate);
For a long time in the past
NSDate *pastdate= [NSDate distantpast];
NSLog (@ "%@", pastdate);
The future of 200s
NSDate *date1 = [NSDate datewithtimeintervalsincenow:200];
Compare date and Date1
Return to an earlier time
NSDate *dateearly =[date earlierdate:date1];
NSLog (@ "date early%@", dateearly);
Return to a later time
NSDate *datelater = [date laterdate:date1];
Time format Conversion Class NSDateFormatter
Create a time conversion object
NSDateFormatter * Dateformatter = [[NSDateFormatter alloc]init];
Format the time of the conversion
Use the time conversion format provided to us by the system
Dateformatter.datestyle =kcfdateformatterfullstyle;
Returns the time corresponding string based on the provided time
NSString *string = [Dateformatter stringfromdate:date];
NSLog (@ "... %@ ", string);
Self-customizing formats
Year Month day hour minute second
Dateformatter.dateformat = @ "Yyyy:MM:dd HH:mm:ss";
NSString *STRINGN = [Dateformatter stringfromdate:date];
NSLog (@ "%@", STRINGN);
Returns the time based on the input string
NSString *str = @ "2014-05-12 12:30:00";
Custom format conversion format based on input time format
NSDateFormatter *format = [[NSDateFormatter alloc]init];
Format.dateformat = @ "Yyyy-mm-dd HH:mm:ss";
Output time based on string nsdate
NSDate *somed = [format datefromstring:str];
NSLog (@ "%@", somed);
Nszone nscalendarcomponent
Nsvalue encapsulated struct C language array
int a[4] ={1,2,3,4};
Create a Nsvalue
Nsvalue *value = [[Nsvalue alloc]initwithbytes:a Objctype: @encode (Int[4])];
int b[10];
Take it out.
[Value getvalue:b];
NSLog (@ "%d", b[2]);
Structural body
struct student{
int age;
};
Variable C age 10
struct student C;
c.age=10;
Encapsulating the structure to the Nsvalue
Nsvalue *value1 = [Nsvalue value:&c withobjctype: @encode (struct student)];
Take the students out
struct student D;
[Value1 getvalue:&d];
NSLog (@ "%d", d.age);
Related Operations for Iosnsdate