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 7945791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:58:40+00:00 2026-06-04T00:58:40+00:00

I am using datePicker to create a timePicker . When i click the textField

  • 0

I am using datePicker to create a timePicker . When i click the textField the picker opens and i have select the time in it, after that selected time will display in that textfield . In my case everything works fine except the time displayed in textfield . It shows the wrong time especially minutes.

This my code for creating picker

timePickerView =  [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320, 260)];
timePickerView.backgroundColor = [UIColor clearColor];

    //create toolbar using new
UIToolbar *toolbar1;
toolbar1 = [UIToolbar new];
    //toolbar.barStyle = UIBarStyleBlackTranslucent;
toolbar1.tintColor = [UIColor colorWithRed:0.627 green:0.627 blue:0.655 alpha:1.000];
    //[UIColor colorWithRed:0.6 green:0.6 blue:0.6 alpha:0.6];
[toolbar1 sizeToFit];
toolbar1.frame = CGRectMake(0, 0, 320, 50);

    //Add buttons
UIBarButtonItem *doneButtone1 = [[UIBarButtonItem alloc]
                                initWithBarButtonSystemItem:UIBarButtonSystemItemDone
                                target:self action:@selector(dismissPicker:)];

    //Use this to put space in between your toolbox buttons
UIBarButtonItem *flexItem1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
                                                                          target:nil
                                                                          action:nil];

    //Add buttons to the array
NSArray *items1 = [NSArray arrayWithObjects: flexItem1, doneButtone1, nil];

    //release buttons
[doneButtone1 release];
[flexItem1 release];

    //add array of buttons to toolbar
[toolbar1 setItems:items1 animated:NO];
[timePickerView addSubview:toolbar1];
[toolbar1 release];

    UIDatePicker *timePicker = [[UIDatePicker alloc]initWithFrame:CGRectZero];
timePicker.autoresizingMask=UIViewAutoresizingFlexibleWidth;
timePicker.datePickerMode = UIDatePickerModeTime;
timePicker.frame = CGRectMake(0, 50.0f, 320.0, 216);
timePicker.tag = 222;
[timePicker addTarget:self action:@selector(selectTime:) forControlEvents:UIControlEventValueChanged];
[timePickerView addSubview:timePicker];
[timePicker release];

And this is the code to display the time in textfield

UIDatePicker *picker =(UIDatePicker *)sender;
DLog(@"%@",picker);

NSDateFormatter *df1 = [[NSDateFormatter alloc] init];
df1.dateStyle = NSDateFormatterMediumStyle;
    //if(picker.tag =222) {
    [df1 setDateFormat:@"HH:MM"];       
    self.timeTF.text = [NSString stringWithFormat:@"%@",[df1 stringFromDate:picker.date]];
    //timeTF.text=[df1 stringFromDate:[NSDate date]];

[df1 release];

It shows hour hand correctly but minute shows always 5

Whats error in my code . can anyone plz help me find out.

  • 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-04T00:58:41+00:00Added an answer on June 4, 2026 at 12:58 am

    This line is the problem:

    [df1 setDateFormat:@"HH:MM"];
    

    MM is month i.e. May = 5

    You should use mm.

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

Sidebar

Related Questions

I'm having trouble with a datepicker that I have created. I am using a
How to create a reminder application from android by using a datepicker and timepicker
I am using the jquery ui datepicker in my app. I have created an
I'm using the Datepicker in two input fields to allow users to select a
I try to create a date range by using the jQuery UI datepicker, using
How do you create the big, scrolling list picker, like the kind that is
I am using jquery UI datepicker on MVC2 to set my startdate picker. When
Im trying to create a simple callback using blocks. I have a MainViewController which
I'm using jqGrid with cell editing and a datepicker. All works well, except that
when using EditorFor(model => model.FieldName) i want to have a generic say datepicker, rich

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.