How to parse date string with this format (Ex: 2012-04-12T14:23:23).
I try with this format string but It's wrong: yyyy-MM-ddThh:mm:ss.
Please help!
            Asked
            
        
        
            Active
            
        
            Viewed 144 times
        
    1
            
            
        
        hungbm06
        
- 1,549
 - 6
 - 24
 - 32
 
3 Answers
7
            
            
        You should escape the letter T:
formatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ss";
        sch
        
- 27,436
 - 3
 - 68
 - 83
 
1
            NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss"];
NSDate *formattedDate = [dateFormatter dateFromString:@"2008-12-3T22:11:30"];
        Niko
        
- 2,543
 - 1
 - 24
 - 29
 
1
            
            
        That's ISO 8601 date format. So, the best way to do this is with a specific date parser that will make life easy for you.
That can be found here http://boredzo.org/iso8601parser/.
Also, have a search on "ISO 8601". You'll find plenty of resources and example, e.g.
What's the right way to parse an ISO8601 date in cocoa?
Is there a simple way of converting an ISO8601 timestamp to a formatted NSDate?
        Community
        
- 1
 - 1
 
        Max MacLeod
        
- 26,115
 - 13
 - 104
 - 132