Convert minutes to seconds
Each minute lasts 60 seconds. Convert the length of a wait into the unit a timer uses.
Duration.components
Simple example
How many seconds are in two minutes?
Start2 min
Result120
let wait = Duration.seconds(2 * 60)
print(wait.components.seconds)
120
Advertisements
Everyday examples
The next bus arrives in seven minutes. How many seconds should its countdown display start with?
Start7 min
Result420
let wait = Duration.seconds(7 * 60)
print(wait.components.seconds)
420
A classroom quiz lasts three minutes. What is its time limit in seconds?
Start3 min
Result180
let wait = Duration.seconds(3 * 60)
print(wait.components.seconds)
180
A kitchen timer rings after five minutes. How many seconds is that?
Start5 min
Result300
let wait = Duration.seconds(5 * 60)
print(wait.components.seconds)
300