时间戳与时间的转化
//实例化一个NSDateFormatter对象
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
//设定时间格式,这里可以设置成自己需要的格式yyyy-MM-dd HH:mm:ss
[dateFormatter setDateFormat:@"yyyy-MM-dd 18:00:00"];
//用[NSDate date]可以获取系统当前时间
//NSString *currentDateStr = [dateFormatter stringFromDate:[NSDate date]];
//输出格式为:2015-9-29 18:00:00
//NSLog(@"currentDateStr---》%@",currentDateStr);
StartTime=[NSString stringWithFormat:@"%ld",(long)[[NSDate date] timeIntervalSince1970]];
//打印StartTime的时间戳
// NSLog(@"starttime---》%@",StartTime);
//---传给后台,初始化时传第二天18点的时间戳
NSTimeInterval a_day1 = 24*60*60;
NSDate *tomorrow1 = [NSDate dateWithTimeIntervalSinceNow:a_day1];
NSDateFormatter *Formatter = [[NSDateFormatter alloc] init];
[Formatter setDateFormat:@"yyyy-MM-dd 18:00:00"];
NSString *currentDateStr = [Formatter stringFromDate:tomorrow1];
NSLog(@"currentDateStr---》%@",currentDateStr);
EndTime=[NSString stringWithFormat:@"%ld",(long)[tomorrow1 timeIntervalSince1970]];
// NSLog(@"endtime--->%@",EndTime);
//---传给前台的入住日期
NSDateFormatter *format1 = [[NSDateFormatter alloc] init];
// [format setDateFormat:@"yyyy-MM-dd"];
[format1 setDateFormat:@"M月d日"];
NSString *TimeStr1=[format1 stringFromDate:[NSDate date]];
// 设置界面显示的文字
self.TimeLab1.text=TimeStr1;
//---传给前台的离店日期,即明天的时间
NSTimeInterval a_day = 24*60*60;
NSDate *tomorrow = [NSDate dateWithTimeIntervalSinceNow:a_day];
NSDateFormatter *format2 = [[NSDateFormatter alloc] init];
// [format setDateFormat:@"yyyy-MM-dd"];
[format2 setDateFormat:@"M月d日"];
NSString *TimeStr2=[format2 stringFromDate:tomorrow];
// 设置界面显示的文字
self.TimeLab2.text=TimeStr2;
//时间戳转格式日期
NSTimeInterval time=[model.createtime doubleValue];
NSDate *detaildate=[NSDate dateWithTimeIntervalSince1970:time];
//NSLog(@"date:%@",[detaildate description]);
//实例化一个NSDateFormatter对象
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
//设定时间格式,这里可以设置成自己需要的格式
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
//赋值给前台的时间Label
_Createtime.text = [dateFormatter stringFromDate: detaildate];