• 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
NSDate, NSDateFormatter, and NSDatePicker
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSDate, NSDateFormatter, and NSDatePicker


  • Subject: NSDate, NSDateFormatter, and NSDatePicker
  • From: Pete Bates <email@hidden>
  • Date: Fri, 13 Jan 2006 07:21:02 -0700

I'm trying to set the display of a date picker to a date retrieved from a database in the form "mm-dd-yyyy". Eliminating the data retrieval code, the code looks like so:

NSString * theDateString;
theDateString=@"05-01-1994";

NSDate * aDate;
aDate=[[NSDate alloc]init];

NSDateFormatter * aDateFormatter;
aDateFormatter=[[NSDateFormatter alloc] init];
[aDateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
[aDateFormatter setDateFormat:@"mm-dd-yyyy"];

aDate=[aDateFormatter dateFromString:theDateString];
[dobPicker setDateValue:aDate];

NSLog(@"The date format is: %@",[aDateFormatter dateFormat]);
NSLog(@"The date string is: %@",theDateString);
NSLog(@"The created date is: %@",aDate);


But here is the Log Output:

The date format is: mm-dd-yyyy
The date string is: 05-01-1994
The created date is: 1994-01-01 00:05:00 -0700

and of course the date picker displays 1/1/1994

Obviously either I'm doing something wrong, or the software is doing something wrong. As hard as it is for me to think so, it could be me... :0
Would someone be so kind as to steer me in the right direction?


Thanks.
Pete
_______________________________________________
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


  • Prev by Date: Re: Notifications when iPods are mounted...
  • Next by Date: Bindings - accessing the model from a seperate window
  • Previous by thread: Re: LDAP and Cocoa
  • Next by thread: Re: NSDate, NSDateFormatter, and NSDatePicker
  • Index(es):
    • Date
    • Thread