• 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
International date formatting
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

International date formatting


  • Subject: International date formatting
  • From: Ben Kazez <email@hidden>
  • Date: Fri, 20 May 2005 01:45:18 -0500

Hi,

I'm new to Cocoa internationalization. Is there a way to format an NSDate according to the current locale so that it displays the weekday, full month name, and date but no year? In other words, in US English I want:

    Thursday, May 19

In French from France, this would be (I think):

    vendredi 19 mai

etc.

Right now I'm using the following code, but it doesn't include the year and worse, it's not changing based on System Preferences > International:

dateFormatter = [[NSDateFormatter alloc] initWithDateFormat:@"" allowNaturalLanguage:NO];
[dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
[dateFormatter setDateStyle:NSDateFormatterFullStyle];
[dateFormatter setTimeStyle:NSDateFormatterNoStyle]; // don't display the time
[dateFormatter setLocale:[NSLocale currentLocale]];


        ...

NSString *ret = [dateFormatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:(milliseconds/1000.0)]];

Thanks so much for your help!

Ben
--
Ben Kazez
http://www.benkazez.com/


_______________________________________________ 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: International date formatting
      • From: Frederick Cheung <email@hidden>
    • Re: International date formatting
      • From: "Sean McBride" <email@hidden>
  • Prev by Date: Re: CoreData, OutlineView, and NSTreeController
  • Next by Date: Plugin support for Apple's Mail application
  • Previous by thread: Re: control font smoothing in an app
  • Next by thread: Re: International date formatting
  • Index(es):
    • Date
    • Thread