Using NSDateComponents I know how to get the day component, but this gives me a value from 1 – 365, right? I need to get the days 1-30 of a specific month, how can I?
For example, I have an NSDate which might be 16th May. I want to be able to get the day, so it returns 16. Being the 16th day of that month (not the 16th day of the year).
Thanks.
EDIT:
I have this:
NSCalendar *cal = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *comps = [cal components:NSDayCalendarUnit fromDate:[[NSUserDefaults standardUserDefaults] objectForKey:@"dateSaved"]];
However comps.day returns 1 when it should equal what the date is saved as, say 4.
The
dayvalue ofNSDateComponentsgives you the day of month according to the given calendar:gives
although February, 4th would be the 35th day of the year.