爱程序网

【代码笔记】获得现在的周的日期

来源: 阅读:

一,代码。

复制代码
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    NSLog(@"现在所在的周:%@",[self getWeekFromLocal]);
    
}
#pragma -mark -functions
//获得现在的周的日期,格式:Wednesday
-(NSString*)getWeekFromLocal{
    NSDate *  senddate=[NSDate date];
    NSDateFormatter  *dateformatter=[[NSDateFormatter alloc] init];
    [dateformatter setDateFormat:@"EEEE"];
    NSString *  locationString=[dateformatter stringFromDate:senddate];
    NSLog(@"locationString:%@",locationString);
    return locationString;
}
复制代码

 

二,输出。

2015-10-19 13:44:18.832 获得现在的周[5628:128503] locationString:Monday

 

 

 
 

关于爱程序网 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助