Hello,
I am trying to get the date from a dateString using the following code snippet:
But the value that is getting logged for newDateString is Dec 22, 2008 instead of today's date. Am I missing something in my code? Suggestions are welcome.
I am trying to get the date from a dateString using the following code snippet:
Code:
NSDate *dateToday = [NSDate date];
NSDateFormatter *dateFormat = [[[NSDateFormatter alloc] init] autorelease];
[dateFormat setDateFormat:@"MMM d, YYYY"];
NSString *sDate = [dateFormat stringFromDate:dateToday];
NSLog(sDate);
NSDate *newDate = [dateFormat dateFromString:sDate];
NSString *newDateString = [dateFormat stringFromDate:newDate];
NSLog(newDateString);
But the value that is getting logged for newDateString is Dec 22, 2008 instead of today's date. Am I missing something in my code? Suggestions are welcome.