Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Convert NSDate to NSString in iOS

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 507
    Comment on it

    This is a simple code snippet which explains's you how to convert NSDate to NSString in iOS.
    Create a string as NSString *myDate & a date formatter. Suppose we have picked a random date from date picker so that the date we have picked is already in NSDate format.

    Now use this code snippet to convert NSDate to NSString-              

    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
    
    [dateFormatter setDateFormat:@"yyyy-MM-dd"];
    NSString *myDate= [self.dateFormatter stringFromDate:datePickr.date];


    Now myDate is a String that contains the date but in NSString format.
    NOTE- Here “datePickr” is the instance of Datepicker that we have used to pick the date.
    Thanks for reading hope it helps.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: