-(void)creatTraceTimer
{
NSString*urlStr=[NSString stringWithFormat:@"http://www.16d1.com/index.php/home/api/gettrace.html?start=%@ 00:00:00&end=%@ 24:00:00&phone=%@",self.date,self.date,self.userPhoneString];
//网址需要编码
NSString *url = [urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
AFHTTPRequestOperationManager *requestManager = [AFHTTPRequestOperationManager manager];
requestManager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html", nil];
[requestManager GET:url parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject)
{
if (responseObject)
{
//字符串,从网上获取的时间戳
NSString*interStr=responseObject[@"data"][100][@"logtime"];
//转换成NSDate类型的
NSDate*date=[NSDate dateWithTimeIntervalSince1970:[interStr integerValue]];
//初始化日期转换格式
NSDateFormatter*formatter=[NSDateFormatter new];
////获取完整的时间
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSString*currentDate=[formatter stringFromDate:date];
NSLog(@" %@ currentDate:%@",date,currentDate);
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error)
{
NSLog(@"error--%@",error);
}];
}