HI all,
i have a date string like this
2011-03-31 13:32:02
i want to convert this date string to display like this
Thursday – March 31, 2011
Please help to solve this
Thanks in advance
Use NSDateFormatter. First initialize the formatter with the appropriate format to parse the source string, something like this:
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
Then use it to parse the date string:
NSDate *date = [formatter dateFromString:string];
Now you can create a new formatter to output in the new format, or just reuse the existing one:
[formatter setDateFormat:@"EEEE - MMMM dd, yyyy"];
NSString *output = [formatter stringFromDate:date];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With