ios 中根据给定日期 获取星期几
2014-11-10 23:11
369 查看
- (NSUInteger)getWeekdayFromDate:(NSDate*)date
02.
03.
{
04.
05.
NSCalendar* calendar = [[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] autorelease];
06.
07.
NSDateComponents* components = [[[NSDateComponents alloc] init] autorelease];
08.
09.
NSInteger unitFlags = NSYearCalendarUnit |
10.
11.
NSMonthCalendarUnit |
12.
13.
NSDayCalendarUnit |
14.
15.
NSWeekdayCalendarUnit |
16.
17.
NSHourCalendarUnit |
18.
19.
NSMinuteCalendarUnit |
20.
21.
NSSecondCalendarUnit;
22.
23.
24.
25.
components = [calendar components:unitFlags fromDate:date];
26.
27.
NSUInteger weekday = [components weekday];
28.
29.
return
weekday;
30.
31.
}- (NSUInteger)getWeekdayFromDate:(NSDate*)date
[code]02.
03.
{
04.
05.
NSCalendar* calendar = [[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] autorelease];
06.
07.
NSDateComponents* components = [[[NSDateComponents alloc] init] autorelease];
08.
09.
NSInteger unitFlags = NSYearCalendarUnit |
10.
11.
NSMonthCalendarUnit |
12.
13.
NSDayCalendarUnit |
14.
15.
NSWeekdayCalendarUnit |
16.
17.
NSHourCalendarUnit |
18.
19.
NSMinuteCalendarUnit |
20.
21.
NSSecondCalendarUnit;
22.
23.
24.
25.
components = [calendar components:unitFlags fromDate:date];
26.
27.
NSUInteger weekday = [components weekday];
28.
29.
return
weekday;
30.
31.
}
- (NSUInteger)getWeekdayFromDate:(NSDate*)date
02.
03.
{
04.
05.
NSCalendar* calendar = [[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] autorelease];
06.
07.
NSDateComponents* components = [[[NSDateComponents alloc] init] autorelease];
08.
09.
NSInteger unitFlags = NSYearCalendarUnit |
10.
11.
NSMonthCalendarUnit |
12.
13.
NSDayCalendarUnit |
14.
15.
NSWeekdayCalendarUnit |
16.
17.
NSHourCalendarUnit |
18.
19.
NSMinuteCalendarUnit |
20.
21.
NSSecondCalendarUnit;
22.
23.
24.
25.
components = [calendar components:unitFlags fromDate:date];
26.
27.
NSUInteger weekday = [components weekday];
28.
29.
return
weekday;
30.
31.
} http://www.cocoachina.com/ask/questions/show/93394
相关文章推荐
- 根据给定日期数计算星期数
- ios 中有关当前日期,星期的获取
- 根据日期字符串获取星期几,日期获取星期,时间获取星期,js获取星期
- android 根据设置的日期获取星期几
- 根据日期获取星期号
- IOS-Swift 获取当前日期 星期
- iOS 获取当前月份一共多少天 ,获取当前某年某月某日, 当前日期星期几
- java 根据日期获取星期
- IOS 根据日期,获取该日期所在周,月,年的开始日期,结束日期 的方法
- ios 日期和星期的获取
- php根据给定日期获取给定日期本周的日期
- js获取星期,根据日期字符串获取星期几,日期获取星期,时间获取星期
- c# 根据日期 获取今天星期几
- ios开发——获取最近几天的日期及对应为一周中得星期几
- ios根据日期获取年月日分秒及常用操作(问题)
- ios根据日期获取当前年,月,日的起始时间和终止时间
- iOS 获取指定日期的时间(年、月、日、星期、时、分、秒等)
- iOS 获取当前日期和星期
- java根据日期获取星期
- 获取当前日期和星期 iOS