NSDate*date = [NSDatedate];
NSLog(@"%@", date);//世界標(biāo)準(zhǔn)時(shí)間
NSLog(@"%@",localDate());
NSLog(@"%@", [datelocalDate]);
NSLog(@"%@", [NSDate localDate]);
//獲取比當(dāng)前時(shí)間快30秒的指定時(shí)間
NSDate*date1 = [NSDate dateWithTimeIntervalSinceNow:30];
NSLog(@"%@", date);
NSLog(@"%@", date1);
NSDate*date2 = [NSDate dateWithTimeIntervalSinceNow:-30];
NSLog(@"%@", date2);
//間隔
NSTimeInterval seconds = [date timeIntervalSince1970];//獲取的是1970年1月1日至今的總秒數(shù)
NSLog(@"%lg", seconds);
NSDate*date3 = [NSDate dateWithTimeIntervalSinceNow:-60];
seconds = [date3timeIntervalSinceNow];//從指定時(shí)間至今的總秒數(shù)
NSLog(@"%lg", seconds);
NSDate*time1 = [NSDate dateWithTimeIntervalSinceNow:-60*60*24];
NSDate*time2 = [NSDate dateWithTimeIntervalSinceNow:60*60*24];
seconds = [time1 timeIntervalSinceDate: time2];
NSLog(@"%lg", seconds);
//指定輸出格式
NSDateFormatter*df = [[NSDateFormatter alloc]init];
df.dateFormat=@"yyyy年MM月dd日HH:mm:ss EEE";
NSString*str = [df stringFromDate: date];
NSLog(@"%@", str);