zoukankan      html  css  js  c++  java
  • IOS

    NSDate:5是坑啊啊!

     1     NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
     2 
     3     [dateFormatter setDateFormat:@"yyyy/MM/dd hh:mm:ss"];
     4 
     5     NSLog(@"0:%@",[dateFormatter stringFromDate:[NSDate date]]);
     6 
     7     
     8 
     9     [dateFormatter setTimeZone:[NSTimeZone systemTimeZone]];
    10 
    11     NSLog(@"1:%@",[dateFormatter stringFromDate:[NSDate date]]);
    12 
    13     
    14 
    15     [dateFormatter setTimeZone:[NSTimeZone defaultTimeZone]];
    16 
    17     NSLog(@"2:%@",[dateFormatter stringFromDate:[NSDate date]]);
    18 
    19     
    20 
    21     [dateFormatter setTimeZone:[NSTimeZone localTimeZone]];
    22 
    23     NSLog(@"3:%@",[dateFormatter stringFromDate:[NSDate date]]);
    24 
    25     
    26 
    27     [dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"Asia/Shanghai"]];
    28 
    29     NSLog(@"4:%@",[dateFormatter stringFromDate:[NSDate date]]);
    30 
    31     
    32 
    33     [dateFormatter setTimeZone:[[NSTimeZone alloc] initWithName:@"Asia/Shanghai"]];
    34 
    35     NSLog(@"5:%@",[dateFormatter dateFromString:[dateFormatter stringFromDate:[NSDate date]]]);
    36 
    37  

    0:2015/02/03 09:41:14

    1:2015/02/03 09:41:14

    2:2015/02/03 09:41:14

    3:2015/02/03 09:41:14

    4:2015/02/03 09:41:14

    5:2015-02-03 01:41:14 +0000

    附带NSDate详情链接:http://www.cnblogs.com/ios-wmm/archive/2013/04/21/3034204.html

  • 相关阅读:
    ORA-00904:标识符无效
    SQL错误:ORA-12899
    ORA-01722:无效数字
    科学记数法
    报表软件公司悬赏 BUG,100块钱1个的真实用意
    Perl--包
    Perl--正则
    Perl use strict 控制变量
    Oracle不删除用户,导入数据
    从别人的角度理解这个世界——Leo鉴书80
  • 原文地址:https://www.cnblogs.com/tx8899/p/4269227.html
Copyright © 2011-2022 走看看