NSDateFormatter is your friend. =)
You use it like this:
NSDateFormatter * f = [[NSDateFormatter alloc] init];
[f setDateFormat:@"YYYY-mm-dd"];
NSLog([f stringFromDate:aDate]);
[f release];
There's also a really handy "dateFromString" method that will parse a
string according to the format string you specify.
This page has lots of good info on what the formatting specifiers are:
http://unicode.org/reports/tr35/tr35-4.html#Date_Format_Patterns
HTH,
Dave
On Apr 2, 2009, at 10:16 PM, Pierce Freeman wrote:
Hi everyone.
I am looking into a way to change the format of what a NSDate
instance shows
to the user. I am aware there is a way to do this with
NSCalendarDate, but
since its documentation says that it may be deprecated in Snow
Leopard - I
would rather not take a chance. Also, I need some way to be able to
create
a NSDate instance out of this format contained in a string (for
example
%Y-%m-%d).
Thanks for any help.
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
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:
http://lists.apple.com/mailman/options/cocoa-dev/davedelong%40me.com
This email sent to davedel...@me.com
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com