I am creating a countdown timer that counts down to the NSDate set in the UIDatePicker . I have a shortcut that shows the date we are counting on, and it works great.
What I'm also trying to add is labels for the number of days left and the number of hours / minutes / seconds remaining in the current day (i.e. no more than 23/59/59). Here is what I did in a minute, but it clearly displays the values ββfor the whole countdown. Hoping someone can help me work out the right 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 assume I'm looking for some quick equivalent of the datetime class that you get in php
source share