ios - Comparing Date and Time Object -


this question has answer here:

i working method , not giving me proper output came know, way comparing date , time object wrong. googled not find relevant solution. want compare date , time object object.

for example:

  if (dtcur >= dtstart && dtcur <= mydt) // 2014-03-24 11:30:00 >= 2014-03-24 11:00:00 & 2014-03-24 11:30:00 <= 2014-03-25 11:00:00   {      // should come here in if condition   } 

but goes in else. means comparison wrong, can me how compare 2 date , time objects. in advance

many objects, including nsdate, have compare: method. use so:

if ([date1 compare:date2] == nsorderedascending) {   // date2 after date1 } else if ([date1 compare:date2] == nsordereddescending) {   // date2 before date1 } else if ([date1 compare:date2] == nsorderedsame) {   // they're both same date } 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -