Re: dateFromString won't accept this string:
Re: dateFromString won't accept this string:
- Subject: Re: dateFromString won't accept this string:
- From: Alex Hall <email@hidden>
- Date: Sun, 22 Nov 2015 18:04:47 -0500
> On Nov 22, 2015, at 5:06 PM, Jerry Krinock <email@hidden> wrote:
>
>
>> On 2015 Nov 22, at 13:12, Alex Hall <email@hidden> wrote:
>>
>> Is there something else I have to do, like tell the formatter what order to expect components to be in?
>
> Yes, and more. You must set the dateFormat property of your date formatter exactly.
>
> Documentation of property ‘dateFormat’ refers you to click on the “Date Formatting Guide”. From there, you click on “Date Formatters”. Once there, scroll down to "Use Format Strings to Specify Custom Formats” and what to your wondering eyes does appear but a list of links to Unicode Consortium standards. Click on the one for the OS version you are targetting. Once there, read the fine print carefully. After 20 minutes or so you should have it working :)
Thanks! I thought, for some reason, that NSDateFormatters could figure out the date from any string with the necessary information—I guess I was thinking of AppleScript.
One follow-up, as I’m looking at all this: is there a reason to use setDateFormat over templates? The header for NSDateFormatter keeps talking about template strings, but online, all I see is setDateFormat(“some formatted string”). I haven’t dug deeply into this yet, so feel free to ignore this question if it’s quite obvious. I thought I’d ask while I was responding, before I go back to the docs. 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
_______________________________________________
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