- 一,转化的方法为
- NSString *timeSp = [NSString stringWithFormat:@"%d", (long)[localeDate timeIntervalSince1970]];
- NSLog(@"timeSp:%@",timeSp);
-
- 二,把获取的时间转化为当前时间
- NSDate *datenow = [NSDate date];
- NSTimeZone *zone = [NSTimeZone systemTimeZone];
- NSInteger interval = [zone secondsFromGMTForDate:datenow];
- NSDate *localeDate = [datenow dateByAddingTimeInterval: interval];
- NSLog(@"%@", localeDate);
-
- 3.把时间戳转化为时间的方法
- NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:1363948516];
- NSLog(@"1363948516 = %@",confromTimesp);
-
- NSDate *datenow = [NSDate date];
- NSTimeZone *zone = [NSTimeZone systemTimeZone];
- NSInteger interval = [zone secondsFromGMTForDate:datenow];
- NSDate *localeDate = [datenow dateByAddingTimeInterval: interval];
- NSLog(@"%@", localeDate);
-
- NSString *timeSp = [NSString stringWithFormat:@"%lld", (long long)[localeDate timeIntervalSince1970]];
- NSLog(@"timeSp:%@",timeSp);
-
- NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:1369189763711/1000];
- NSLog(@"1363948516 = %@",confromTimesp);
-
-
-
-
- NSDateFormatter *dateFormatter1 = [[[NSDateFormatter alloc] init] autorelease];
- [dateFormatter1 setDateFormat:@"yyyy-MM-dd 00:00:00"];
- NSString *currentDateStr1 = [dateFormatter1 stringFromDate:[NSDate date]];
- NSLog(@"凌晨时间:%@",currentDateStr1);
- NSString *timeSp1 = [NSString stringWithFormat:@"%lld", (long long)[localeDate timeIntervalSince1970]];
- NSLog(@"凌晨时间戳:%@",timeSp1);
-
- NSString *timeSp2 = [NSString stringWithFormat:@"%lld", (long long)[localeDate timeIntervalSince1970]-24*60*60];
- NSLog(@"昨天凌晨时间戳:%@",timeSp2);
posted @
2015-06-11 11:08
anjing123
阅读(
294)
评论()
编辑
收藏
举报