0

I have two dates, one is in the UTC timezone and the other is in New Zealand. I need to compare if one date is greater than the other.

How do I do this? Do I need to convert them to the same timezone first?

jscs
  • 63,694
  • 13
  • 151
  • 195
williamsandonz
  • 15,864
  • 23
  • 100
  • 186

2 Answers2

2

No. You can just compare them with the NSDate comparison function, which returns ascending/descending (kind of crazy semantics, but works).

How to compare two NSDates: Which is more recent?

Community
  • 1
  • 1
Rob
  • 11,446
  • 7
  • 39
  • 57
2

NSDates don't have timezones. They represent absolute moments in time. As long as you made the NSDates correctly -- i.e., if you created them via an NSDateFormatter, it has a timezone that needs to be set -- you can compare them directly.

jscs
  • 63,694
  • 13
  • 151
  • 195