美文网首页
iOS 获取当前日期星期几

iOS 获取当前日期星期几

作者: 任任run | 来源:发表于2017-03-20 16:32 被阅读1002次

    //获取当前日期星期几

    NSArray *weekdays = [NSArray arrayWithObjects:@"周日", @"周一", @"周二", @"周三", @"周四", @"周五", @"周六", nil];

    NSTimeZone *timeZone = [[NSTimeZone alloc] initWithName:@"Asia/Shanghai"];

    [calendar setTimeZone: timeZone];

    NSDate *date = [NSDate date];

    NSCalendarUnit calendarUnit = NSWeekdayCalendarUnit;

    NSDateComponents *theComponents = [calendar components:calendarUnit fromDate:date];

    NSLog(@"%@", [weekdays objectAtIndex:theComponents.weekday]);

    相关文章

      网友评论

          本文标题: iOS 获取当前日期星期几

          本文链接:https://www.haomeiwen.com/subject/wahinttx.html