Re: NSDate with Format?
Re: NSDate with Format?
- Subject: Re: NSDate with Format?
- From: Dave DeLong <email@hidden>
- Date: Thu, 02 Apr 2009 22:22:33 -0600
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 (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
_______________________________________________
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