Following code I can use for storing the value of UILabel into a string. And Value of string is store into NSDate.
NSString *star = [[NSString alloc]init];
star = lbtInDate.text;
NSString *end = [[NSString alloc]init];
end = lblOutDate.text;
NSDateFormatter *dateFormatter1=[[NSDateFormatter alloc]init];
[dateFormatter1 setDateFormat:@"yyyy-MM-dd HH:mm"];
NSDate *sdate= [dateFormatter1 dateFromString:star];
NSDate *edate=[dateFormatter1 dateFromString:end];
but the value of sdate and edate is shows nil. so please help how can i store the value of UILabel into NSDate for compare.
Your code is perfectly valid only the
lbtInDate.text;andlblOutDate.text;respect the date format. If not your NSDate’s will be null.If
lblOutDate.text;is something like@"2002-12-23", your date format should be@"yyyy-MM-dd"and so on.Data Formatting Guide