//获取当前时间
-(NSString *)getCurrentTime {
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyMMddHHmmss"];
NSString*dateTime = [formatter stringFromDate:[NSDate date]];
self.CurrentTime = dateTime;
NSLog(@"当前时间是===%@",_CurrentTime);
return _CurrentTime;
}
//获取当前时间
-(NSString*)getCurrentTime {
NSDateFormatter*formatter = [[NSDateFormatteralloc]init]; [formattersetDateFormat:@"yyy-MM-dd"];
NSString*dateTime = [formatterstringFromDate:[NSDate date]];
// NSString *str1 = [dateTime stringByReplacingOccurrencesOfString:@"-" withString:@""];
self.CurrentTime= dateTime;
NSLog(@"当前时间是===%@",_CurrentTime);
return_CurrentTime;
}
//获取当前时间的时间戳
-(NSString*)getCurrentTimestamp{
NSDate* dat = [NSDatedateWithTimeIntervalSinceNow:0];
NSTimeIntervala=[dattimeIntervalSince1970];
NSString*timeString = [NSStringstringWithFormat:@"%0.f", a];//转为字符型
returntimeString;
}
最后推荐一个技术交流群,里面大神很多! 529043462