Search code examples
iosnsdatenscalendar

How do I know what day a given date is?


For example, given a date 13/09/2013(it is Saturday), how can I know what day it is in code? are there some methods in NSCalendar or NSdate can calculate this for me?


Solution

  • You can use a DateFormatter to get the day of the week for a specific date as a string. You can also use NSDateComponents to get an integer value that represents the day of week.

    See this SO post and answers...

    https://stackoverflow.com/a/4269211