squimer / DatePickerDialog-iOS-Swift

Date picker dialog for iOS
MIT License
582 stars 177 forks source link

time #14

Closed DreamTekis closed 8 years ago

DreamTekis commented 8 years ago

How to get time from dialog? even though mode id Time dialog returning date

jojost1 commented 8 years ago

Like to do this as well.

lfarah commented 8 years ago

Hey guys, I'm the new admin of this page. Both modes return an NSDate and in order to get the time, you have to do the following:

let calendar = NSCalendar.currentCalendar()
let comp = calendar.components([.Hour, .Minute], fromDate: date)
let hour = comp.hour
let minute = comp.minute