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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:33:56+00:00 2026-05-25T09:33:56+00:00

i want to convert an nsstring into nsdate .i have created a global variable

  • 0

i want to convert an nsstring into nsdate .i have created a global variable where i saving the date picked from the datepicker and then converting this variable to nsdate us the datefromstring function.But the string is not getting converted to date.What may be the problem.

TTimePickercontroller:
This is the class in which i have the code for the picker

-(NSString *)convertDueDateFormat{
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setLocale:[NSLocale currentLocale]];
    [dateFormatter setFormatterBehavior: NSDateFormatterBehavior10_4];
    [dateFormatter setTimeStyle:NSDateFormatterShortStyle];
    dateString = [dateFormatter stringFromDate:datePicker.date];

    return dateString;
//dateString is an nsstring variable that has been declared globally.
}

TAddAlarmController.
this is another class in which i want to convert the dateString varibale into nssdate
-(IBAction)save{

    timepicker = [[TTimePickerController alloc]init];
    NSDateFormatter* df = [[NSDateFormatter alloc] init];
    [df setDateFormat:@"hh:mm"];
    d = [df dateFromString:dateString];
    NSLog(@"%@", d);
    //Here i am using the dateFromString function and converting the string variable dateString into nsdate variable d .in dateString variable value is getting passed but in d the value is not getting passed. 


}
Please help me in solving the problem.Thanks
  • 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-05-25T09:33:56+00:00Added an answer on May 25, 2026 at 9:33 am
    Try this code this will help you because I run this code successfully and return time.
    
    UIDatePicker *pickerView = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 44, 0, 0)];  
    pickerView.datePickerMode = UIDatePickerModeDate;  
    pickerView.hidden = NO;  
    pickerView.date = [NSDate date];
    [self.view addSubview:pickerView];
    NSString *dateString;   
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"hh:mm"];
    dateString = [dateFormatter stringFromDate:pickerView.date];
    NSLog(@"String into Date:--->%@",dateString);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an NSString object and want to convert it into a std::string .
Hi I want to convert the NSString into Byte array. if I have string
I want to convert NSString to NSDate but UIPickerView shows current datedatePicker=[[UIDatePicker alloc]init]; datePicker.userInteractionEnabled=YES;
I want to convert NSString into NSDate. So I tried following code : NSDateFormatter
How can I convert NSString into NSNumber. For ex. I have @0100, I want
I have an NSString which I want to convert into an NSDecimalNumber . The
I have an NSString like @Hello World and want to convert that into an
I am having a date format 16-11-2011. but I want to convert it into
I have an RGB hex code like #ffffff as NSString and want to convert
I want convert string value into date in my project because I am fetching

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.