关于NSDateFormat

来源:互联网 发布:上海 数据 恢复 编辑:程序博客网 时间:2024/06/07 11:27

1.关于NSDateFormat属性dateFormat的制定。

The followering is an offical example:

NSDateFormat *dateFormat= [[NSDateFormat alloc] init];

dateFormat.dateFormat = @"yyyy-MM-dd 'at' HH:mm"] ;

NSDate *date = [NSDate date];

NSString *dateStr = [dateFormat stringFormDate:date];

NSLog(@"dateString = %@",dateStr);


//For US English, the output may be:  dateString = 2001-01-02 at 13:00


1. It user yyyy to specify the year component. A common mistake is to use YYYY.yyyy speifies the calendar year whereas YYYY specifies the year (of "Week of Year"),used in the ISO year-week calendar. In most cases,yyyy and YYYY yield the same number,however they may be different. Typically you should use the calendar year.

2. The representation of the time may be 13:00. In iOS,however, if the user has switched 14-Hour Time to Off ,the time may be 1:00 pm.


另外,通过实践也可以看到 “HH”指定24小时制,"hh"制定12小时制的

0 0
原创粉丝点击