• 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
Re: Date to string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Date to string


  • Subject: Re: Date to string
  • From: j o a r <email@hidden>
  • Date: Mon, 28 Nov 2005 10:57:20 +0100


On 28 nov 2005, at 07.17, JuanC wrote:

The matter is that I need put a static text with the date of today in a window.
The best way sould be with the european format: DD-MM-YY (28 Nov. 2005).
I don“t know what is the best way: NSDate or NSCalendar... for get the date and NSText or NSTextView... for draw the string.

Something like this (probably full of bugs, I typed it in Mail):

NSCalendarDate *calendarDate = [NSCalendarDate calendarDate];
[myTextField setStringValue: [calendarDate descriptionWithCalendarFormat: @"%d-%m-%Y"]];


On 28 nov 2005, at 10.04, Uli Kusterer wrote:

ISO dates are also the closest you can get to a "European" date (and are used in Sweden).

Wohoo! We're the greatest!

I think you can also use an NSDateFormatter with an NSTextField.

Though formatters are mostly valuable for controlling user input, right? Well, at least on versions of Mac OS X prior to 10.4. It seems to have changed a lot recently:


<http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ ObjC_classic/Classes/NSDateFormatter_index.html>

If you want to output a date in a format that is appropriate for the current locale, it seems that NSDateFormatter is the way to go. If you, on the other hand, just want to use a specific date format string, you can use the simple way I outlined above.

j o a r



Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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

References: 
 >Date to string (From: JuanC <email@hidden>)

  • Prev by Date: Re: Finding the user's processor type...
  • Next by Date: Re: Finding the user's processor type...
  • Previous by thread: Re: Date to string
  • Next by thread: Re: Date to string
  • Index(es):
    • Date
    • Thread