I have an NSDate that I get from UIDatepicker.
IBOutlet UIDatePicker *dueDate; NSDate *selectedDate = [dueDate date];
How to get a month out dueDateof shape int? (1 for January, February 2, etc.)
dueDate
int
NSCalendar *calendar = [NSCalendar currentCalendar]; NSDateComponents *components = [calendar components:NSMonthCalendarUnit fromDate:[dueDate date]]; NSInteger month = [components month];
use -[NSCalendar components:fromDate:]for example the example here:
-[NSCalendar components:fromDate:]
http://developer.apple.com/iphone/library/documentation/Cocoa/Reference/Foundation/Classes/NSCalendar_Class/Reference/NSCalendar.html
NSDateFormatter *dateFormat = [[[NSDateFormatter alloc] initWithDateFormat:@"%m" allowNaturalLanguage:NO] autorelease]; int month = [[dateFormat stringFromDate:dueDate] intValue];
Source: https://habr.com/ru/post/1706079/More articles:https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1706074/jquery-modal-opens-to-full-page&usg=ALkJrhgGDuqdBEN116-jtzlshxLc8V9KKgReporting Services: Overriding the default setting with an expression in a linked report - linked-listHow to get empty href request parameters? - javascriptWhy does this variable function crash the 4th parameter in Windows x64? - cPolymorphism or inheritance in JSON with Java and Ruby - javaHow do I change this declaration? - c ++jquery select text - javascriptJQuery JEditable оставаться в режиме редактирования при ошибке - jqueryWhat is a Select statement to return column names in a table - sqlHow to bind SqlDatasource ConnectionString property to function - asp.netAll Articles