NSDateFormatter dateFromString for 24hr date gives wrong time

Posted by krusty on Stack Overflow See other posts from Stack Overflow or by krusty
Published on 2011-02-10T06:44:08Z Indexed on 2011/02/10 7:25 UTC
Read the original article Hit count: 253

Filed under:
|
|

I want to add event to native calender.I am having problem in getting date accurate time from string. I have set locale,24 hr format. but still getting the same bug.

EKEvent *event = [EKEvent eventWithEventStore:self.eventStore];
   event.title=txtTitle.text;

   NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];

  NSLocale *locale =[[[NSLocalealloc]initWithLocaleIdentifier:@"en_US_POSIX"]autorelease];  

  [dateFormatter setLocale:locale];
  [dateFormatter setDateFormat:@"dd/MM/yyyy HH:mm"];


  event.startDate=[dateFormatter dateFromString:lblStartDate.text];

My lblStartDate.text is:-10/02/2011 12:12 PM

And event.startDate is getting set as:-2011-02-10 06:42:00 GMT

Can anyone help???

© Stack Overflow or respective owner

Related posts about iphone

Related posts about nsdateformatter