大家好,我想比较两个日期并执行一些操作我被困在洞天试图尽我所能,但我知道我可能遗漏了一些东西或做错了什么,任何帮助将不胜感激。在我的代码下面
-(void)dailyCalendarViewDidSelect:(NSDate *)date
{
//You can do any logic after the view select the date
NSDateFormatter *dateformat = [[NSDateFormatter alloc] init];
[dateformat setDateStyle:NSDateFormatterMediumStyle];
[dateformat setDateStyle:NSDateFormatterMediumStyle] ;
datestring1= [dateformat stringFromDate:date]; // date value by current selected date from my cal view
NSLog(@"%@",datestring1);//output May 5, 2015
// NSLog(@"%@",date);//output 2015-05-05 15:56:32 +0000
datestring2 = [dateformat stringFromDate:mydate];//already fetched value
NSLog(@"%@",datestring2);// output May 5, 2015
// NSLog(@"%@",mydate);// output 2015-05-05 08:47:16 +0000
if (datestring1 == datestring2) {
NSLog(@"good to go");//not able to get this value
}
/*//even i try this block too
NSDateFormatter *dateFormat = [[NSDateFormatter alloc]init];
[dateFormat setDateFormat:@"yyyy-MM-dd"];
mydate1 = [[NSDate alloc]init];
mydate1 = [dateFormat dateFromString:datestring1];
NSLog(@"%@",mydate1);//otpt null
mydate2 = [[NSDate alloc]init];
mydate2 = [dateFormat dateFromString:datestring2];
NSLog(@"%@",mydate2);//otpt //null
if (mydate1 == mydate2) {
NSLog(@"good to go");//getting value without matching condition
}
*/
}
请看一下任何帮助都会有所帮助提前谢谢