#pragma mark-Get month day and week + (NSString *) stringfromdate{//Add date Nscalendar *calendar = [[Nscalendar alloc] Initwith Calendaridentifier:nsgregoriancalendar]; Nsdatecomponents *comps = [[Nsdatecomponents alloc] init]; Nsinteger unitflags = Nsyearcalendarunit | Nsmonthcalendarunit | Nsdaycalendarunit | Nsweekdaycalendarunit | Nshourcalendarunit | Nsminutecalendarunit | Nssecondcalendarunit; NSDate * senddate=[nsdate Date]; NSDateFormatter *dateformatter=[[nsdateformatter alloc] init]; [Dateformatter setdateformat:@ "Yyyy-mm-dd"]; Comps = [Calendar Components:unitflags fromdate:senddate]; NSString *locationstring=[dateformatter Stringfromdate:senddate]; NSString *date_weekstr = [NSString stringwithformat:@ "%@%@", Locationstring,[self Week:[comps weekday]]; return DATE_WEEKSTR;} #pragma mark-Reckoning week + (NSString *) Week: (Nsinteger) week{nsstring *weekstr=nil; if (week==1) {[email protected] "Sunday"; }else if (week==2) {[EMAIL&NBSp;protected] "Monday"; }else if (week==3) {[email protected] "Tuesday"; }else if (week==4) {[email protected] "Wednesday"; }else if (week==5) {[email protected] "Thursday"; }else if (week==6) {[email protected] "Friday"; }else if (week==7) {[email protected] "Saturday"; } return weekstr;}
IOS gets month day, week