Get the Day from the date in iOS sdk

后端 未结 7 482
无人共我
无人共我 2021-01-16 12:36

In my app, want to get the day (i.e. Sunday, Monday,etc.) from the date.

My code is as follow:

NSDate *currentDate = [NSDat         


        
7条回答
  •  清酒与你
    2021-01-16 13:33

    NSDateFormatter* theDateFormatter = [[NSDateFormatter alloc] init];
    [theDateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
    [theDateFormatter setDateFormat:@"EEEE"];
    NSString *weekDay =  [theDateFormatter stringFromDate:[NSDate date]];
    

提交回复
热议问题