iOS – string formatted date selector date is closed

I have a UIDatePicker with only month, day and year. I am trying to output this selected date to a TextField using the following code:

-(IBAction) dateChanged:(id)sender
{
NSDate *date = datePicker.date;
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"M/d/YYYY"];
expirationDateField.text = [df stringFromDate:date];
[df release];
}

< p>For most dates, this is valid, but for some reason, when I choose January 1, 2009 or January 2, 2009, I end up with “1/1/2008” or “1 /2/2008” (this is not specific to 2009). I think this is a time zone issue, but if this is the case, it will not show the wrong year of January 2. Any ideas?

Use lowercase yyyy this year.

Uppercase YYYY returns the date The start year of the week.
See Unicode Date Format Patterns.

I have a UIDatePicker with only month, day and year. I am trying to use the following code to select this Set date output to TextField:

-(IBAction) dateChanged:(id)sender
{
NSDate *date = datePicker.date;
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"M/d/YYYY"];
expirationDateField.text = [df stringFromDate:date];< br /> [df release];
}

For most dates, this is valid, but for some reason, when I choose January 1, 2009 or 2009 On the 2nd of the month, I ended up with “1/1/2008” or “1/2/2008” (this is not specific to 2009). I think this is a time zone issue, but if that is the case, it will not be displayed Wrong year on January 2nd. Any ideas?

Use lowercase yyyy this year.

Uppercase YYYY returns the start year of the week in which the date is located.
See Unicode Date Format Patterns.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3898 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.