I'm creating a countdown timer that counts down to an NSDate
set in a UIDatePicker
. I have a label that shows the date we're counting down to and that works fine.
What I'm also trying to add is labels for the number of whole days left and number of hours/minutes/seconds left in the current day (i.e. never more than 23/59/59) Here's what I've done at the minute but it obviously shows the values for the whole countdown. Hoping someone can help me work out the correct logic here.
let secondsLeft = sender.date.timeIntervalSinceDate(NSDate())
hoursLabel.text = String(secondsLeft % 3600)
minutesLabel.text = String((secondsLeft / 60) % 60)
secondsLabel.text = String(secondsLeft % 60)
I guess what I'm looking for is some swift equivalent of the datetime
class you get in php