The digital time stamp and the time mutual grasping exchange
Note: Because Java is more accurate than PHP time, so, the time of the background data Java is 13 bits, and PHP is 10 bits, iOS time to scratch only support 10 digits, so if the Java writing backstage, the number/1000 on the line. The following are the specific procedures:
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
Formatter.dateformat = @ "Yyyy-mm-dd HH:mm:ss";
NSDate *date = [[NSDate alloc] init];
NSString *datestr = [formatter stringfromdate:date];
NSLog (@ "%@", datestr);
Time is converted to digital timestamp/*
-(Nstimeinterval) Timeintervalsincedate: (NSDate *) anotherdate;
@property (readonly) nstimeinterval Timeintervalsincenow;
@property (readonly) nstimeinterval timeIntervalSince1970;
* *
Nsinteger numtime = date.timeintervalsince1970;
NSString *numtimestr = [NSString stringwithformat:@ "%ld", Numtime];
NSLog (@ "%@", numtimestr);
The digital time is converted to a timestamp, if it is 13 digits divided by 1000, or after 3 digits are removed
nsdate *date2 = [NSDate datewithtimeintervalsince1970:numtime];
NSString *DATESTR2 = [formatter stringfromdate:date2];
NSLog (@ "%@", DATESTR2);