0

I am trying to make the date which is packed from the date picker become an NSDate, so I can create an event.

@IBOutlet var pckStartDate: NSDatePicker!
@IBOutlet var pckEndDate: NSDatePicker!


var dateFmt1 = NSDateFormatter()
    dateFmt1.dateFormat = "yyyy-MM-dd"
    var _startDate:NSDate = dateFmt1(pckStartDate)

I obviously can't use the dateFromString() method because pckEndDate is not a string. How can I get this work? Does pckEndDate need to be converted to a String and then NSDate?

Any help appreciated.

Yelims01
  • 47
  • 1
  • 8

1 Answers1

0

You're looking for the dateValue property:

let startDate: NSDate = pckStartDate.dateValue
let startDateString: String = dateFmt1.stringFromDate(startDate)
rob mayoff
  • 375,296
  • 67
  • 796
  • 848