PDA

View Full Version : NSDatePicker




mahaboob
Sep 17, 2008, 06:18 AM
Hi all,
I'm currently working with NSDatePicker. When I'm accessing string from the NSDatePicker I got the complete date like: Wednesday, September 17, 2008 4:37:03 PM GMT+05:30. My application needs only :
Wednesday, September 17, 2008 . How can I get this ?

Thanks in advance



robbieduncan
Sep 17, 2008, 06:36 AM
As is clear in the documentation use the dateValue (http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSDatePicker_Class/Reference/Reference.html#//apple_ref/occ/instm/NSDatePicker/dateValue) method to retrieve the selected date.

You can then use descriptionWithCalendarFormat:timeZone:locale: (http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDate_Class/Reference/Reference.html#//apple_ref/occ/instm/NSDate/descriptionWithCalendarFormat:timeZone:locale:) to format the date into a string.

Or use a NSDateFormatter (http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDateFormatter_Class/Reference/Reference.html) to format the date.