views:

35

answers:

1
NSDateFormatter* dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss.sss"];
self.date = [dateFormatter dateFromString:dateString];

the code works fine with this string

  • "2007-06-10 06:31:54.935"

but doesn't work with this one (it returns nil if the time is set to 0):

  • "2007-06-10 00:00:00.000"
+3  A: 

Try using @"yyyy-MM-dd HH:mm:ss.SSS" (uppercase S for the fractional seconds).
See Date Format Patterns guide.

aBitObvious