I need to retrieve the date from a UIDatePicker (Preferably I would also like to be specify the format as well. For example, mmdd would output the string 1209. Any string that reasonably parsed would work as well.
Thanks in advance.
You need to use the date property:
NSDate *myDate = datePicker.date;
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"cccc, MMM d, hh:mm aa"];
NSString *prettyVersion = [dateFormat stringFromDate:myDate];
BTW, it's not obvious but you can add specific non-parsed text by encompassing it inside single quotes in the format:
[dateFormat setDateFormat:@"'Game-'yyyyMMdd-HHmm'.xml'"];
NSString *filenameVersion = [dateFormat stringFromDate:myDate];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With