[Solved] How to convert Objective-C to date format yyyy-MM-dd [duplicate]

Assuming it is a timestamp, you can do the following to convert it into a NSDate object: NSDate *date = [NSDate dateWithTimeIntervalSince1970:1460510348510/1000.0]; which prints out 2016-04-13 01:19:08 +0000 if you NSLog it. — How you can parse that response into an actual timestamp is described below: Parsing JSON (date) to Swift solved How to convert … Read more

[Solved] date not showing in correct manner

Try to change like this: In ViewDidload: firstdate = [[NSCalendar currentCalendar] dateByAddingUnit:NSCalendarUnitDay value:-6 toDate:[NSDate date] options:nil]; // And below method -(void)dateChange { NSArray *labelArray = @[flabel, slabel, tlabel, folabel, fivlabel,sixlabel,sevenlabel]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; NSCalendar *calendar = [NSCalendar currentCalendar]; dateFormatter.dateFormat = @”ddMMM”; for (NSInteger i = 0; i < 7; ++i) { NSDate … Read more

[Solved] Calculate next date in week

Use [NSCalendar currentCalendar] to get NSDateComponents from the current date, especially NSWeekdayCalendarUnit and NSWeekOfYearCalendarUnit. the components will have a member weekday, that ranges from 1 — sunday to 7 — saturday. if it is 1 or 2, create a new componets with weekday 2, if it is 7, add one to weekOfYear and set weekday … Read more

[Solved] To convert a particular format to NSDate [closed]

Use this code to get the Current Date NSDateFormatter *dateFor=[[NSDateFormatter alloc]init]; NSString *currentDateString = @”2014-01-08T21:21:22.737+05:30″; [dateFor setDateFormat:@”yyyy-MM-dd’T’HH:mm:ss.SSSZZZZ”]; NSDate *currentDate = [dateFor dateFromString:currentDateString]; NSLog(@”CurrentDate:%@”, currentDate); 5 solved To convert a particular format to NSDate [closed]