• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Parsing a string into a NSDate
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Parsing a string into a NSDate


  • Subject: Parsing a string into a NSDate
  • From: Bert Torfs <email@hidden>
  • Date: Wed, 15 Mar 2006 20:01:49 +0100

Just noticed that my 7-year old dateparsing routine fails when the date format (as set in the international preferences) requires Unicode applications. So I tried the following replacement.

NSString* shortDateFormat;
shortDateFormat = [[NSUserDefaults standardUserDefaults] objectForKey:NSShortDateFormatString]; // "%e/%m/%y"
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateFormat:shortDateFormat];
NSDate* ObjCDate = [dateFormatter dateFromString:inStringDate]; // inStringDate = "15/03/06" result = 01/03/06 (????????)


The problem with this code is that todays date ("15/03/06") is translated into 01/03/06 - the day part being wrong. What did I do wrong?

Thanks a lot,

Bert _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
  • Follow-Ups:
    • Re: Parsing a string into a NSDate
      • From: Nick Zitzmann <email@hidden>
  • Prev by Date: Fwd: Disabling the Table Panel
  • Next by Date: Re: Getting a bullet into a NSString
  • Previous by thread: Re: Stats libraries
  • Next by thread: Re: Parsing a string into a NSDate
  • Index(es):
    • Date
    • Thread