swift 5 get current date code example

Example 1: 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)

Example 2: swift 5 get current date date

Swift 5

let currentDate = Date()

Example 3: swift 5 get current date

let date = Date()
let calendar = Calendar.current
let hour = calendar.component(.hour, from: date)
let minutes = calendar.component(.minute, from: date)