almost 5 years ago
If we want to get the time intervals between the start time and end time then use the following code-
it will return the array of hours according to the start time and end time.
+ (NSMutableArray *)getTimeIntervals:(NSString *)startTime andEndTime:(NSString *)endTime { NSMutableArray *hoursArray=[[NSMutableArray alloc]init]; NSDateFormatter *dateFormatter1=[[NSDateFormatter alloc]init]; [dateFormatter1 setDateFormat:@"hh:mm a"]; NSDate *startString = [dateFormatter1 dateFromString:startTime]; NSDate *endString = [dateFormatter1 dateFromString:endTime]; NSTimeInterval interval = [endString timeIntervalSinceDate:startString]; NSInteger t1=(NSInteger)interval; NSInteger hours=t1/3600; for (int i=0;i<=hours; i++) { NSString *meridian; NSDate *plusOneHour ; if(i==0) plusOneHour=startString; else plusOneHour = [startString dateByAddingTimeInterval:60.0f * 60.0f]; NSCalendar *calendar = [NSCalendar currentCalendar]; NSDateComponents *components = [calendar components:(NSCalendarUnitHour | NSCalendarUnitMinute) fromDate:plusOneHour]; NSInteger hour = [components hour]; meridian=hour>=12?@"PM":@"AM"; if(hour>12){ hour=hour-12; } NSString *string = [NSString stringWithFormat:@"%ld %@", (long)hour,meridian]; startString=plusOneHour; [hoursArray addObject:string]; } return hoursArray; }
Starting with Chrome version 45, NPAPI is no longer supported for Google Chrome. For more information, see Chrome and NPAPI (blog.chromium.org).
Firefox and Microsoft Internet Explorer are recommended browsers for websites using java applets.
Chrome Version Support
Are you sure, you want to delete this comment?
Sign up using
0 Comment(s)