NSDateFormatter *inputDateFormatter = [[NSDateFormatter alloc] init]; NSString *inputDateStr = @"yyyy/MM/dd HH:mm:ss"; [inputDateFormatter setDateFormat:inputDateStr]; NSString *intputDateStr = @"2000/01/02 03:04:05"; NSDate *inputDate = [inputDateFormatter dateFromString:intputDateStr]; NSLog(@"%@ -> %@", inputDateStr, [inputDate description]); [inputDateFormatter release];
from:http://d.hatena.ne.jp/nakamura001/20100525/1274802305
ps:
http://www.wangdg.com/?p=207
http://blog.163.com/fuxiaohui@126/blog/static/13174582620123234483974/