NSDateFormatter *dateFormatter=[[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"EEE MMM dd yyyy HH:mm:ss zzz (zzzz)"];
NSLog(@"%@",[dateFormatter stringFromDate:[NSDate date]]);
Abow代码给出了Fri Feb 12 2016 14:11:16 GMT+5:30 (India Standard Time)
日期格式结果,但我需要Fri Feb 12 2016 14:11:16 GMT 05:30 (India Standard Time)
日期结果格式
答案 0 :(得分:1)
试试这个。
NSDateFormatter *dateFormatter=[[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"EEE MMM dd yyyy HH:mm:ss zzz (zzzz)"];
[dateFormatter stringFromDate:[NSDate date]];
NSString *date=[dateFormatter stringFromDate:[NSDate date]];
//Replace "+" with Space""
NSString *finalTimezone = [date stringByReplacingOccurrencesOfString:@"+"
withString:@" "];
<强>输出:强>