I am using Swift 3 and trying to get the current hour. Below is the code i have written to get the current hour but it gives an error.
let date = Date()
let calendar = Calendar.current
let hour = calendar.component(.hour, from: date) // error
What could be the reason for this, all the sample code based on Swift 3 shows the same code snippet to get the current hour but it just don't seem to work. Please can anyone point out what could be wrong here. Thanks.