NSDate *date = [NSDate date];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
dateStyle
formatter.dateStyle = NSDateFormatterNoStyle;
NSLog(@"date1:%@",[formatter stringFromDate:date]);
//date1:
-
NSDateFormatterShortStyle
:
formatter.dateStyle = NSDateFormatterShortStyle;
NSLog(@"date2:%@",[formatter stringFromDate:date]);
//date2:17/11/24
-
NSDateFormatterMediumStyle
:
formatter.dateStyle = NSDateFormatterMediumStyle;
NSLog(@"date3:%@",[formatter stringFromDate:date]);
//date3:2017年11月24日
-
NSDateFormatterLongStyle
:
formatter.dateStyle = NSDateFormatterLongStyle;
NSLog(@"date4:%@",[formatter stringFromDate:date]);
//date4:2017年11月24日
-
NSDateFormatterFullStyle
:
formatter.dateStyle = NSDateFormatterFullStyle;
NSLog(@"date5:%@",[formatter stringFromDate:date]);
//2017年11月24日 星期五
timeStyle
formatter.timeStyle = NSDateFormatterNoStyle;
NSLog(@"time1:%@",[formatter stringFromDate:date]);
//time1:
-
NSDateFormatterShortStyle
:
formatter.timeStyle = NSDateFormatterShortStyle;
NSLog(@"time2:%@",[formatter stringFromDate:date]);
//time2:11:15
-
NSDateFormatterMediumStyle
:
formatter.timeStyle = NSDateFormatterMediumStyle;
NSLog(@"time3:%@",[formatter stringFromDate:date]);
//time3:11:15:29
-
NSDateFormatterLongStyle
:
formatter.timeStyle = NSDateFormatterLongStyle;
NSLog(@"time4:%@",[formatter stringFromDate:date]);
//time4:GMT+811:15:29
-
NSDateFormatterFullStyle
:
formatter.timeStyle = NSDateFormatterFullStyle;
NSLog(@"time5:%@",[formatter stringFromDate:date]);
//time5:中国标准时间11:15:29