I have an NSDate
object called reservationDate and I want to fetch day, month and hour from the Date. However, I'm getting wrong values. How can I get these values?
The value of the reservationDate object
reservationDate NSDate
2016-08-05 21:00:00 UTC
thus I expect to get 5 as a day and 21 as a hour however I'm receiving 6 as a day and 0 as a hour. Should I expect something else?
let unitFlags: NSCalendarUnit = [.Hour, .Day, .Month, .Year]
let components = NSCalendar.currentCalendar().components(unitFlags, fromDate: reservationDate)
let day = components.day
let hour = components.hour