IOS中NSTimeZone小结
来源:互联网 发布:时间序列数据分析例子 编辑:程序博客网 时间:2024/05/01 17:22
NSDate *date = [NSDate date];
NSLog(@"date:%@",date);
//系统时区
NSTimeZone *zone = [NSTimeZone systemTimeZone];
NSData *data = [zone data];
NSLog(@"data:%@",data);
//时间缩写
NSString *abbStr = [zone abbreviation];
NSLog(@"abbStr:%@",abbStr);
//当地时区
NSTimeZone *localTime = [NSTimeZone localTimeZone];
NSLog(@"localTime:%@",localTime);
//和格林尼治时间差
NSInteger timeOff = [zone secondsFromGMT];
//视察转化
NSDate *timeOffDate = [date dateByAddingTimeInterval:timeOff];
NSLog(@"timeOffDate:%@",timeOffDate);
//所有地区名称
NSArray *zoneArrs = [NSTimeZone knownTimeZoneNames];
NSLog(@"zoneArrs:%@",zoneArrs);
//遍历
for (NSString *names in zoneArrs) {
//时区
NSTimeZone *timeZone = [[NSTimeZone alloc] initWithName:names];
//设置格式
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateStyle:kCFDateFormatterFullStyle];
[dateFormatter setTimeZone:timeZone];
NSString *string = [dateFormatter stringFromDate:date];
NSLog(@"string:%@,[timeZone name]:%@",string,[timeZone name]);
[dateFormatter release];
[timeZone release];
}
0 0
- IOS中NSTimeZone小结
- NSTimeZone小结
- NSTimeZone小结
- iOS NSTimeZone
- IOS-Frameworks-Foundation-NSTimeZone
- iOS NSDate,NSDateFormatter,NSTimeZone,NSTimeInterval
- NSTimeZone
- NSTimeZone
- NSTimeZone
- iOS时间那点事--NSTimeZone
- IOS中UIViewController小结
- iOS中scrollsToTop小结
- IOS中Block小结
- iOS中NSMutableAttributedString 小结
- iOS开发中iOS小结
- iOS时间处理(NSDate、NSDateComponents、NSCalendar、NSDateFormatter、NSTimeZone)
- IOS 时区日期处理及定时 (NSDate,NSCalendar,NSTimer,NSTimeZone)
- IOS中scrollsToTop问题小结
- 4 views
- org.json.simple使用详解
- 【9】Windows客户端C/C++编程规范“建议”——风格
- 6、 表格
- nGrinder 界面和简评
- IOS中NSTimeZone小结
- linux用户行为审计
- 一次Link2001错误的解决
- ssh 别名登录
- Object有哪些公用方法?
- Swift学习-集合类型(四)
- html文档结构
- html5input保留2位小数
- CWinApp