0

I have:

NSString *dateOfBirth = @"1997-01-13T00:00:00+1000"

I then present to the user a date picker to allow them to choose a date to compare with the above dateOfBirth string representation of a date.

Assuming they choose 1997-01-13 as the NSDate to compare, I convert dateOfBirth to NSDate but get back 1997-01-12 14:00:00 +0000 (when NSLogged) which when compared to what the user selected would not result in NSOrderedSame. I have not played around with NSDates much. How can handle this to get back NSOrderedSame when the two dates are compared.

pnizzle
  • 6,243
  • 4
  • 52
  • 81
  • 1
    Have you tried comparing them? They look the same to me. Your original one is at midnight, but 10 hours later than UTC. The one from the date picker is a time 10 hours earlier at 14:00 the day before, but shows that it is in UTC. That's the same time. – Tom Harrington Jul 16 '15 at 05:03
  • @TomHarrington you are right. I noticed that too, a bit later though. I ended up picking out the date, month and year components only for each date and comparing those instead. The difference in time is what was causing an issue for me. Same date, but different times, don't know why I didn't pick that up earlier. Needed some coffee I guess. i will post my solution soon. – pnizzle Jul 16 '15 at 05:10
  • @TomHarrington I actually made a mistake in my question details. Apologies. I meant to have two dates with the same timezone, same week day, same year and same month, but different clock time. For example two people born on the same date. They may have been born at different times of that day, but the fact that it was on the same day means they have the same birthday. The only way I managed to get the comparison to return NSOrderedSame for such a comparison was to only pick out the day, month, and year components. In other words disregarding the difference in time of day. – pnizzle May 31 '16 at 05:55

0 Answers0