I am stuck for a while parsing date in string using NSDateFormatter
Date in string is in below format
1/1/2011 12:00:00 AM
Below is the code I use to parse
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setDateFormat:@"MM/dd/yyyy hh:mm:ss"];
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];
[dateFormatter setDateStyle:NSDateFormatterShortStyle];
NSDate *date = [[NSDate alloc]init];
date = [dateFormatter dateFromString:@"1/1/2011 12:00:00 AM"];
This code works with date @"12/31/2011" and format @"MM/dd/yyyy"
Please help
use my bellow custom method and parse that date into another format...
use this method like bellow..
Set any Format which you want in
getwithFormat
parameter and set format indateFormat
parameter which you have with your Date string...OUTPUT IS => Converted String : 01/01/2011
Try this