Given the following code:
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@-MM-dd'T'HH:mm:ss];
NSLog(@Date from String: %@, [formatter dateFromString:@
2013-09-08T00:36:40]);
The log produces: Date from String: (null)
For other strings from the same
On Mar 31, 2014, at 10:56 AM, D. Felipe Torres warorf...@gmail.com wrote:
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@-MM-dd'T'HH:mm:ss];
NSLog(@Date from String: %@, [formatter dateFromString:@
2013-09-08T00:36:40]);
The log produces: Date
I just pasted it from CodeRunner.
I changed 00 for 0X where X is a number and it worked.
On Mon, Mar 31, 2014 at 3:09 PM, Jens Alfke j...@mooseyard.com wrote:
On Mar 31, 2014, at 10:56 AM, D. Felipe Torres warorf...@gmail.com
wrote:
NSDateFormatter *formatter = [[NSDateFormatter alloc]
Well, try parsing using -getObjectValue:forString:range:error: instead, so you
get an error message.
Also, try setting the locale of the formatter to en_US_POSIX so you don’t get
any localization effects.
(I just got both of these suggestions from “Parsing Date Strings” in Apple’s
“Data
Shortly after I replied I tried using that locale and no luck.
My code now looks like this:
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@-MM-dd'T'HH:mm:ss];
NSLocale *locale = [NSLocale localeWithLocaleIdentifier:@en_US_POSIX];
[formatter
What OS/version/SDK?
___
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
On Mar 31, 2014, at 12:04 , D. Felipe Torres warorf...@gmail.com wrote:
I found out it only fails under my current timezone:
I went to stackoverflow to read the outcome, and for completeness I’ll report
here that the above isn’t true.
It doesn’t fail under your particular timezone. It fails
I missed the rest of this thread so I don't know what platform you're on, but
recent OS X has new date/time manipulation functions that can help you with
ensuring you're talking about a valid time. AFAIK, they're not yet in iOS (grr).
On Mar 31, 2014, at 14:31 , Quincey Morris