时间转时间戳
NSString *timeSp = [NSString stringWithFormat:@"%d", (long)[datenow timeIntervalSince1970]];
NSLog(@"timeSp:%@",timeSp); //时间戳的值
时间戳转时间(1)
NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:1296035591];
NSLog(@"1296035591 = %@",confromTimesp);
NSString *confromTimespStr = [formatter stringFromDate:confromTimesp];
NSLog(@"confromTimespStr = %@",confromTimespStr);
时间戳转时间(2)
NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
[formatter setDateStyle:NSDateFormatterMediumStyle];
[formatter setTimeStyle:NSDateFormatterShortStyle];
[formatter setDateFormat:@"yyyyMMddHHMMss"];
NSDate *date = [formatter dateFromString:@"1283376197"];
NSLog(@"date1:%@",date);
[formatter release];