NSDateFormatter的格式字符串
2011-02-11 14:58
375 查看
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];
//[dateFormatter setDateFormat:@"hh:mm:ss"]
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss.SSS"
];
//毫秒
NSLog(@"Date%@"
, [dateFormatter stringFromDate:[NSDate date]]);
[dateFormatter release];
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];
//[dateFormatter setDateFormat:@"hh:mm:ss"]
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss.SSS"
];
//毫秒
NSLog(@"Date%@"
, [dateFormatter stringFromDate:[NSDate date]]);
[dateFormatter release];
Specifier | Description |
---|---|
%% | A '%' character |
%a | Abbreviated weekday name |
%A | Full weekday name |
%b | Abbreviated month name |
%B | Full month name |
%c | Shorthand for “%X %x ", the locale format for date and time |
%d | Day of the month as a decimal number (01-31) |
%e | Same as %d but does not print the leading 0 for days 1 through 9 (unlike strftime() , does not print a leading space) |
%F | Milliseconds as a decimal number (000-999) |
%H | Hour based on a 24-hour clock as a decimal number (00-23) |
%I | Hour based on a 12-hour clock as a decimal number (01-12) |
%j | Day of the year as a decimal number (001-366) |
%m | Month as a decimal number (01-12) |
%M | Minute as a decimal number (00-59) |
%p | AM/PM designation for the locale |
%S | Second as a decimal number (00-59) |
%w | Weekday as a decimal number (0-6), where Sunday is 0 |
%x | Date using the date representation for the locale, including the time zone (produces different results from strftime() ) |
%X | Time using the time representation for the locale (produces different results from strftime() ) |
%y | Year without century (00-99) |
%Y | Year with century (such as 1990) |
%Z | Time zone name (such as Pacific Daylight Time; produces different results from strftime() ) |
%z | Time zone offset in hours and minutes from GMT (HHMM) |
相关文章推荐
- iOS NSDateFormatter将一串字符串转换成时间格式
- [IPhone开发]NSDateFormatter的格式字符串
- [IPhone开发]NSDateFormatter的格式字符串
- 分享 [IPhone开发]NSDateFormatter的格式字符串
- IOS---------NSDateFormatter的格式字符串
- NSDateFormatter的格式字符串
- NSDateFormatter的格式字符串
- NSDateFormatter 日期格式
- NSDateFormatter调整时间格式的代码
- NSDateFormatter setDateFormat 自定义日期/时间格式
- NSDateFormatter格式详解
- iOS-NSDateFormatter 格式说明
- NSDateFormatter设定日期格式
- NSDateFormatter setDateFormat 自定义日期/时间格式
- 用c来解决`NSDateFormatter`来处理很多日期格式
- Objective-C中的日期格式器NSDateFormatter
- iOS关于NSDate、NSString、NSDateFormatter设置时间格式等问题
- 用NSDateFormatter调整时间格式的代码
- NSDateFormatter 格式参考
- IOS学习 NSDateFormatter的时间显示格式