如何将本地时间转化为"指定时区"的时间

  1. NSDateFormatter *formatter =  [[NSDateFormatter alloc] init];

  2. [formatter setDateFormat:@"yyyy-MM-dd hh:mm:ss"];

  3. NSTimeZone* timeZone = [NSTimeZone timeZoneWithName:@"Asia/Shanghai"];

  4. [formatter setTimeZone:timeZone];

  5. NSString *loctime = [formatter stringFromDate:date];

  6. [formatter release];
----------------------------------------------------------------------------------------------------
不管用户如何设置,,均获得24小时显示(其中的HH,强制指定为24时制)

  1. NSDateFormatter * formatter =   [[NSDateFormatter alloc] init];

  2. [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];

  3. NSString *loctime = [formatter stringFromDate:date];

  4. [formatter release]

from:  http://bbs.cnsoftware.cn/thread-647-1-1.html

你可能感兴趣的:(thread,html,bbs)