How to get the current time of SWIFT?

I want to get the current time, so far I have completed this:

let date = NSDate() 
let calender = NSCalendar.currentCalendar()
let components = calender.component([.Hour, .Minute], fromDate: date)

Then I try to get the hour of the component< /p>

let hour = components.hour

This gave me “value of type” Int “no member’hour'”. Any suggestions?

change

let components = calender.component([.Hour, .Minute], fromDate: date)

to

let components = calender.components([.Hour, .Minute], fromDate: date)

I want to get the current time, so far I have completed this:

< /p>

let date = NSDate()
let calender = NSCalendar.currentCalendar()
let components = calender.component([.Hour, .Minute], fromDate: date)

Then I try to get the hour of the component

let hour = components.hour

This gives me the “value of type “Int” no Member’hours'”. Any suggestions?

Change

let components = calender.component([.Hour, .Minute] , fromDate: date)

to

let components = calender.components([.Hour, .Minute], fromDate: date)

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4163 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.