Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7779753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:43:06+00:00 2026-06-01T18:43:06+00:00

This seems strange… I am using a UidatePicker in an actionSheet. on click of

  • 0

This seems strange… I am using a UidatePicker in an actionSheet. on click of a button i display the action sheet. when i select the date as 31st December 2012 and click done, the date i get is 31st December 2013. It is happening for all the years and only on 31st December. Am i doing anything incorrect? Here is my code

-(void)dateButtonPressed:(id)sender //Method invoking the action sheet on button press
{
actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];

CGRect pickerFrame = CGRectMake(0, 40, 0, 0);

closingdatePicker = [[UIDatePicker alloc] initWithFrame:pickerFrame];
closingdatePicker.tag=10;
closingdatePicker.datePickerMode=UIDatePickerModeDate;


pickerToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
pickerToolbar.barStyle = UIBarStyleBlackTranslucent;
[pickerToolbar sizeToFit];

NSMutableArray *barItems = [[NSMutableArray alloc] init];

UIBarButtonItem *cancelBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(DatePickerCancelClick:)];
[barItems addObject:cancelBtn];

UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
[barItems addObject:flexSpace];

UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(DatePickerDoneClick:)];
[barItems addObject:doneBtn];

[pickerToolbar setItems:barItems animated:YES];

[actionSheet addSubview:pickerToolbar];
[actionSheet addSubview:closingdatePicker];
[actionSheet showInView:self.view];
[closingdatePicker release];
[actionSheet setBounds:CGRectMake(0,0,320, 464)];
[actionSheet release];
}

- (void)DatePickerDoneClick:(id)sender{    //doen click and my date is stored in selectedDate
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"MM/dd/YYYY"];

//Gets our picker
UIDatePicker *ourDatePicker = (UIDatePicker *) [actionSheet viewWithTag:10];

NSDate *selectedDate = [ourDatePicker date];

closingDate.text=[NSString stringWithFormat:@"%@",[formatter stringFromDate:selectedDate]];

[actionSheet dismissWithClickedButtonIndex:0 animated:YES];
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T18:43:08+00:00Added an answer on June 1, 2026 at 6:43 pm

    just use yyyy instead of YYYY this happens some time with dateformater

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I ran across this case of UnboundLocalError recently, which seems strange: import pprint def
It seems I tend to attract strange issues. This time, I have written a
This seems very strange to me but I have a script that I'm running
This seems strange to me but I am sure there is an explanation If
This seems very strange, I recently upgraded to Xcode 4.2 and I'm about to
I know this might seem strange on the face on it but, if I
This seems to be an overlooked area that could really use some insight. What
This seems like a pretty softball question, but I always have a hard time
This seems very noisy to me. Five lines of overhead is just too much.
This seems trivial, but I've never had to worry about it before and my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.