tags:

views:

451

answers:

1

I need to compair current time with two time rang, its work fine in every case but when I check "12:00 PM" to "01:30 PM", it give me wrong value.

NSComparisonResult timeStart=[@"01:02 PM"  compare:@"12:00 PM"];
NSComparisonResult timeEnd=[@"01:02 PM" compare:@"01:30 PM"];

both timeStart and timeEnd are -1?

where timeStart is bigger so it should be 1 which is not.

Please help......

+1  A: 

You are comparing two strings, not two times. You need to first construct NSDate objects with say NSDateFormatter's dateFromString: method, then do your comparison.

freespace