0

Below is my code:-

-(NSDate *)getReminderDatetime
{
    NSArray *tempStrings = [self.selectedReminderInfo.reminderTime componentsSeparatedByString:@":"];
    NSInteger hour = [[tempStrings firstObject] integerValue];
    NSInteger min = [[tempStrings lastObject] integerValue];
    NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier: NSCalendarIdentifierGregorian];
    NSDate *reminderDate = [calendar dateBySettingHour:hour minute:min second:0 ofDate:self.selectedDate options:0];
    //reminderDate = [GeneralHelper convertToLocalTime:reminderDate];
    return reminderDate;
}

The result of hour is 15 and min is 29. So by right, reminderDate should be 2017-06-16 15:29:00 +0000. However, it is returning -8 hours which is 2017-06-16 09:29:00 +0000. How can I fix it to the value I want ?

Nirav D
  • 71,513
  • 12
  • 161
  • 183
SPUDERMAN
  • 187
  • 1
  • 1
  • 10
  • set local in dataeformatter – Himanshu Moradiya Jun 17 '17 at 05:33
  • @HimanshuMoradiya I need NSDate in 24 hours format instead of NSString. Is it possible ? – SPUDERMAN Jun 17 '17 at 05:52
  • Some things to consider: Is your local timezone 8 hours from UTC? Have you tried setting the timezone of `calendar`? How are you displaying the time? How does `NSLog` display a time? Work your way through those and you'll probably solve your problem. HTH – CRD Jun 17 '17 at 06:17

0 Answers0