I have been looking over StackOverflow and have not found any answers yet, if I missed a post which answers this I apologize and would be grateful for the link.
I am trying to change a string “prod.Start” into a NSDate type for comparison with today’s date. The following code myDate returns “1753-01-01 00:00:00 -075258”
CODE:
NSDateFormatter *format = [[NSDateFormatter alloc] init];
[format setFormatterBehavior:NSDateFormatterBehavior10_4];
[format setDateFormat:@"MM/dd/yyyy hh:mm:ss a"];
NSDate *myDate = [format dateFromString: prod.Start]; //prod.Start = 1/1/1753 12:00:00 AM
Any suggestions/tips would be appreciated.
Thanks
edit:
Works now : thanks for all the help.
What I thought was an error was 12AM = 0 o’clock AM
I tried 12PM and output was “1753-01-01 12:00:00 -075258”
Thank you for also explaining the “-075258” = PST was curious about that.
You’re on the right track. The NSDate compare functions only work with that standard format, so that is the right output (though if my code doesn’t work, check Max’s solution). You now need to compare this to today’s date like so…
That should give you what you’re looking for.