zoukankan      html  css  js  c++  java
  • NSDate 时区转换问题

    一:

      NSDateFormatter *dateFormater = [[NSDateFormatter alloc]init];    
        [dateFormater setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
        NSTimeZone* localzone = [NSTimeZone localTimeZone];
        NSTimeZone* GTMzone = [NSTimeZone timeZoneForSecondsFromGMT:0];
        [dateFormater setTimeZone:GTMzone];
        [dateFormater setTimeZone:localzone];
        
        NSString *aStrDate = [[NSString alloc]initWithString:[dateFormater stringFromDate:[NSDate date]]];
        NSString *sendText = [NSString stringWithFormat:@"app测试发送:%@", aStrDate];
        NSLog(@"the send --> %@",sendText);

    二:

    1. NSTimeZone* localzone = [NSTimeZone localTimeZone];  
    2. NSTimeZone* GTMzone = [NSTimeZone timeZoneForSecondsFromGMT:0];  
    3. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];  
    4. [dateFormatter setDateFormat:GLOBAL_TIMEFORMAT];  
    5. [dateFormatter setTimeZone:GTMzone];  
    6. NSDate *bdate = [dateFormatter dateFromString:GLOBAL_TIMEBASE];  
    7. NSDate *day = [NSDate dateWithTimeInterval:(3600 + [localzone secondsFromGMT]) sinceDate:bdate];  
    8. NSString *text = [dateFormatter stringFromDate:day];  
  • 相关阅读:
    PHP安装linux
    nginx 安装
    Redis安装
    linux启动http服务
    收藏的有用的网页
    laravel框架部署后有用命令
    .net 报错access to the path c: empimagefilesmsc_cntr_0.txt is denied
    oracle 触发器
    学习Auxre记录
    mysql数据库索引
  • 原文地址:https://www.cnblogs.com/cocoajin/p/3261876.html
Copyright © 2011-2022 走看看