Skip to content

Instantly share code, notes, and snippets.

@hasokeric
Last active March 18, 2016 13:13
Show Gist options
  • Save hasokeric/fe2f6695bef13eebf5da to your computer and use it in GitHub Desktop.
Save hasokeric/fe2f6695bef13eebf5da to your computer and use it in GitHub Desktop.
Epicor: Convert Seconds Since Midnight to an Actual Time
public static string ConvertSecondsToTime(int secondsSinceMidnight)
{
// Initialize Variables
int hour = 0, minutes = 0, seconds = 0;
decimal hourSecondsLeftOver = 0;
// Get Hour
hour = (int) secondsSinceMidnight / 3600;
hourSecondsLeftOver = (decimal) secondsSinceMidnight - (hour * 3600);
// Get Minutes
minutes = (int) hourSecondsLeftOver / 60;
// Get Seconds
seconds = (int) hourSecondsLeftOver - (minutes * 60);
// Return Result
return String.Format("{0:00}:{1:00}:{2:00}", hour, minutes, seconds);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment