码迷,mamicode.com
首页 > 其他好文 > 详细

获得当前是星期几

时间:2014-07-23 15:48:19      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:color   re   c   div   ar   line   

+(NSString *)getWeekday

{
    NSDate *date = [NSDate date];
    NSDateComponents *componets = [[NSCalendar autoupdatingCurrentCalendar] components:NSWeekdayCalendarUnit fromDate:date];
    NSString *weekday = [self getWeekdayWithNumber:[componets weekday]];
    return weekday;
}
 
//1代表星期日、如此类推
+(NSString *)getWeekdayWithNumber:(int)number
{
    switch (number) {
        case 1:
            return @"星期日";
            break;
        case 2:
            return @"星期一";
            break;
        case 3:
            return @"星期二";
            break;
        case 4:
            return @"星期三";
            break;
        case 5:
            return @"星期四";
            break;
        case 6:
            return @"星期五";
            break;
        case 7:
            return @"星期六";
            break;
        default:
            return @"";
            break;
    }
}

获得当前是星期几,布布扣,bubuko.com

获得当前是星期几

标签:color   re   c   div   ar   line   

原文地址:http://www.cnblogs.com/sgdkg/p/3863145.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!