To get a string with minutes and seconds from a Double
value in Swift, you can calculate the minutes and seconds separately using some basic math operations. Here's a code snippet to achieve this:
main.swift357 chars11 lines
In this code:
formatTimeFromSeconds
function that takes a Double
representing the total time in seconds.totalTimeInSeconds
value and print the formatted time.This function will work for converting a Double
value representing total seconds into a string with minutes and seconds in the format "mm:ss".
main.swift0 chars1 lines
gistlibby LogSnag