Answers for "swift get time from date"

3

swift get current time

let date = Date()
let calendar = Calendar.current
let hour = calendar.component(.hour, from: date)
let minutes = calendar.component(.minute, from: date)
Posted by: Guest on February-24-2020
0

swift get current hour

let date = Date() // save date, so all components use the same date
let calendar = Calendar.current // or e.g. Calendar(identifier: .persian)

let hour = calendar.component(.hour, from: date)
let minute = calendar.component(.minute, from: date)
let second = calendar.component(.second, from: date)
Posted by: Guest on June-09-2020
0

swift get current hour

let hour = Calendar.current.component(.hour, from: Date())
Posted by: Guest on June-09-2020

Code answers related to "Swift"

Browse Popular Code Answers by Language