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

  • Home
  • SEARCH
  • 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 7876267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:08:31+00:00 2026-06-03T03:08:31+00:00

i am having two textfields,fromdate and todate.how to get different dates from the same

  • 0

i am having two textfields,fromdate and todate.how to get different dates from the same datepicker.i tried something which ended up in getting the same date in both the textfields when the date is changed.

-(IBAction)dateValueChanged:(id)sender
{
        UIDatePicker *picker = (UIDatePicker *)sender;
        NSDate *dateSelected1 = [picker date];
        NSDate *dateSelected2 = [picker date];

        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
        [dateFormatter setDateFormat:@"dd-MM-yyyy"];
        self.fromTextField.text = [dateFormatter stringFromDate:dateSelected1];
       self.toTextField.text = [dateFormatter stringFromDate:dateSelected2];
}
  • 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-03T03:08:32+00:00Added an answer on June 3, 2026 at 3:08 am

    You could implement the UITextFieldDelegate Protocol for both your TextFields textFieldDidBeginEditing: Method along with setting the tag property for each TextField so they are easily identifiable…

    Then when textFieldDidBeginEditing: is called, you could read the tag of the textfield that has begun editing and set that as a global value so you can find out what textfield the date picker should change.. example:

    - (void)textFieldDidBeginEditing:(UITextField *)textField {
    
         someGlobalNSInteger = textField.tag; //the current text field tag is now globally set
    
    }
    
    -(IBAction)dateValueChanged:(id)sender {
        UIDatePicker *picker = (UIDatePicker *)sender;
        NSDate *dateSelected1 = [picker date];
        //NSDate *dateSelected1 = [picker date];
    
        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
        [dateFormatter setDateFormat:@"dd-MM-yyyy"];
    
        //self.fromTextField.text = [dateFormatter stringFromDate:dateSelected1];
        //self.toTextField.text = [dateFormatter stringFromDate:dateSelected2];
    
        UITextField *activeTextField = (UITextField*)[self viewWithTag:someGlobalNSInteger]; //gets text field what is currently being edited
        [activeTextField setText:[dateFormatter stringFromDate:dateSelected1]];
    
    }
    

    However if you’re not allowing the text field to be editable (so it can’t bring the keyboard up) you may need some other way of figuring out what textField should get the updated date but i’ll leave that to you.

    Hope it helps

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

Sidebar

Related Questions

hello friends i am having two frames, each frame has a html form which
I'm having two versions of PHP scripts. I forgot which lines I modified in
Having two lists of same object type. I want to join them using an
I am having two flash applications on a same web page. Lets say one
I am having two fields in my form. One is date field which is
Goal: Having two buttons that should be enable to add or delete data from
I am having two text fields From, To.Here i want to do many things
I having Two class(ClassA,ClassB).From ClassB i have to call a method of ClassA while
there are two different textfields in my applications and i set the .delegate property
Having two forms, each in it's own jQuery UI tab, how can I post

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.