How to find weekday from today's date using NSDate?

后端 未结 5 2013
春和景丽
春和景丽 2020-12-05 07:13

I know that I can figure out today\'s date by [NSDate date]; but how would I find out today day of the week, like Saturday, Friday etc.

I know that

5条回答
  •  执笔经年
    2020-12-05 07:53

    let today = Date()
    let day = Calendar.current.dateComponents([.weekday], from: today).weekday
    if ( day == 5)
        {
            yourText.text = "Thursday"
        }
    

提交回复
热议问题