If minutes are < 9 add a 0 before it

Viewed 1113

with this code you can save the current time but if the Minutes < 9 than it gives you the time in 5:9 instead of 5:09. How can you fix this?

let date = Date()
let calendar = Calendar.current
let hour = calendar.component(.hour, from: date)
let minutes = calendar.component(.minute, from: date)
let Tijd = "\(hour) : \(minutes)"
1 Answers
Related