2015-05-27 74 views

回答

1

服務器返回的日期到這個甲,所以你需要修剪日期和(),並得到實際數量這是自1970年時間戳,然後你可以將其轉換爲NSDate的,我用一個簡單的方法,這

- (NSDate*) converDateStringToNSDate:(NSString *)string 
{ 
// Expect date in this format "/Date(1268123461843)/" 
int start = [string rangeOfString:@"("].location+1; 
int end = [string rangeOfString:@")"].location; 
NSRange range = NSMakeRange(start,end-start); 
unsigned long long milliseconds = [[string substringWithRange:range] longLongValue]; 
NSLog(@"%llu",milliseconds); 
NSTimeInterval interval = milliseconds/1000; 
return [NSDate dateWithTimeIntervalSince1970:interval]; 
}