Let's say I have something like 30-10-2025 12:53
, how could I convert that to an NSDate? I guess there's some class that takes this plus an format string that tells it how the date looks as a string, so it can parse it... where must I look?
views:
80answers:
3
+5
A:
You can use NSDateFormatter
NSDateFormatter *k= [[NSDateFormatter alloc] init];
[k setFormat:@"your string format"] //ex @"MM/DD/yyyy hh:mm:ss"
NSDate *d=[k dateFromString:yourString];
[k release]
Here is a reference DateFormatter ref
Daniel
2010-06-18 14:22:37
Mac OS X 10.5 and later, and all versions of iOS, expect format strings according to this specification: http://unicode.org/reports/tr35/tr35-6.html#Date_Format_Patterns
Alex
2010-06-18 14:34:27
+1
A:
You can find a few examples here on using NSDateFormatter
Date Formatter Examples Take 1
John
2010-06-18 15:56:42