Hey, welcome new subscribers!
I’m back doing Daily Coding Tips for the foreseeable future.
Here’s a quick way to create a countdown timer that counts down to WWDC:
The main thing I’m doing here is using a timer that publishes every second.
When the timer is received in the .onReceive
modifier, we need to find the difference between the two dates. I calculated the time that the WWDC keynote is likely to start as 165434800 seconds since 1970 using Epoch Converter.
The difference between this interval and the current time given by the timer is in seconds, so it needs to be converted to days, hours, minutes and seconds using the formatter.
The remaining time is then displayed like this: