• 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
NSDateFormatter misbehaving
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSDateFormatter misbehaving


  • Subject: NSDateFormatter misbehaving
  • From: email@hidden
  • Date: Wed, 02 Feb 2011 21:14:28 +0000

Here is the code I'm using to format a date string:


NSDate *date = [NSDate date];

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateStyle:NSDateFormatterBehavior10_4];
[dateFormatter setDateStyle:NSDateFormatterShortStyle];
// check placed here
[dateFormatter setDateFormat:@"EEE_MMM_dd_yyyy"];

NSString * filenameDate = [dateFormatter stringFromDate:date];

What I'm expecting is something like this:
Tue_Feb_02_2011

What I'm getting is this:
02/02/2011

I even inserted this line just after the setDateFormat to see just what the formatter would return as its format
NSString * df = [dateFormatter dateFormat];


I get this back
02/02/2001

What gives? I've used NSDateFormatter before with no problems. I assume I've missed something silly, but I just don't see it.
Thanks
_______________________________________________


Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSDateFormatter misbehaving
      • From: Ken Thomases <email@hidden>
  • Prev by Date: Re: Custom Accessors in Core Data
  • Next by Date: Re: NSDateFormatter misbehaving
  • Previous by thread: Re: Custom Accessors in Core Data
  • Next by thread: Re: NSDateFormatter misbehaving
  • Index(es):
    • Date
    • Thread