1 //获取系统时间
2 NSDate * date=[NSDate date];
3 NSDateFormatter *dateformatter=[[NSDateFormatter alloc] init];
4 [dateformatter setDateFormat:@"HH:mm"];
5 NSString * locationString=[dateformatter stringFromDate:date];
6
7 //[dateformatter setDateFormat:@"YYYY-MM-dd-HH-mm-ss"];
8 //NSString * morelocationString=[dateformatter stringFromDate:senddate];
9
10 //获得系统日期
11 NSCalendar * cal=[NSCalendar currentCalendar];
12 NSUInteger unitFlags=NSDayCalendarUnit|NSMonthCalendarUnit|NSYearCalendarUnit;
13 NSDateComponents * conponent= [cal components:unitFlags fromDate:senddate];
14 NSInteger year=[conponent year];
15 NSInteger month=[conponent month];
16 NSInteger day=[conponent day];
17 NSString * nsDateString= [NSString stringWithFormat:@"%4d年%2d月%2d日",year,month,day];
18
19 [dateformatter release];