I want to be able to validate a date.
It's valid entry is 4 characters with a mmyy mask.
I want to make sure that the value entered is indeed a date.
Thanks in advance.
I want to be able to validate a date.
It's valid entry is 4 characters with a mmyy mask.
I want to make sure that the value entered is indeed a date.
Thanks in advance.
User NSDateFormatter
's -setDateFormat:
and -dateFromString:
methods. If the string is not in the correct format, you will get nil
returned from -dateFromString:
.
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"mmyy"];
NSDate *date = [dateFormatter dateFromString:YOUR_STRING];
If (date) {
// CORRECT
}