Created
October 19, 2017 14:34
-
-
Save codejockie/1cbc48ff93e21fbd51df86e41d610af9 to your computer and use it in GitHub Desktop.
Time converter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
public class Program { | |
static void Main() { | |
Console.WriteLine(timeFormatter(54000)); | |
} | |
static string timeFormatter(int seconds) { | |
float h = seconds / 3600; | |
float m = (seconds % 3600) / 60; | |
float s = seconds % 60; | |
var time = ""; | |
if (h < 10) { | |
time += "0" + h + ":"; | |
} else { | |
time += h + ":"; | |
} | |
if (m < 10) { | |
time += "0" + m + ":"; | |
} else { | |
time += m + ":"; | |
} | |
if (s < 10) { | |
time += "0" + s; | |
} else { | |
time += s; | |
} | |
return time; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment