#include-once ;~ MsgBox(0,'Time Difference is:', _FormatDuration(175)) ;minutes ;~ MsgBox(0,'Time Difference is:', _FormatDuration(38000)) ;hours ;~ MsgBox(0,'Time Difference is:', _FormatDuration(450684)) ;days ;~ MsgBox(0,'Time Difference is:', _FormatDuration(175, True)) ;minutes ;~ MsgBox(0,'Time Difference is:', _FormatDuration(38000, True)) ;hours ;~ MsgBox(0,'Time Difference is:', _FormatDuration(450684, True)) ;days Func _FormatDuration($nInputSeconds, $bMS = False) $nInputMSeconds = 0 Local $ElapsedMessage = "" If $bMS Then $nInputMSeconds = Mod($nInputSeconds, 1000) $nInputSeconds = $nInputSeconds / 1000 $ElapsedMessage = __GetSecondsAndMS($nInputSeconds, $nInputMSeconds) Else $ElapsedMessage = __GetSeconds($nInputSeconds) EndIf If $nInputSeconds >= 60 Then $ElapsedMessage = __GetMinutes($nInputSeconds, $ElapsedMessage) EndIf If $nInputSeconds >= 3600 Then $ElapsedMessage = __GetHours($nInputSeconds, $ElapsedMessage) EndIf If $nInputSeconds >= 86400 Then $ElapsedMessage = __GetDays($nInputSeconds, $ElapsedMessage) EndIf Return($ElapsedMessage) EndFunc Func __GetSecondsAndMS($nInputSeconds, $nInputMSeconds) Return(StringFormat("%02d.%03d", Mod($nInputSeconds, 60), $nInputMSeconds)) EndFunc Func __GetSeconds($nInputSeconds) Return(StringFormat("%02d", Mod($nInputSeconds, 60))) EndFunc Func __GetMinutes($nInputSeconds, $ElapsedMessage) Return(StringFormat("%02d:%s", Mod(Floor($nInputSeconds / 60), 60), $ElapsedMessage)) EndFunc Func __GetHours($nInputSeconds, $ElapsedMessage) Return(StringFormat("%02d:%s", Mod(Floor($nInputSeconds / 60 / 60), 24), $ElapsedMessage)) EndFunc Func __GetDays($nInputSeconds, $ElapsedMessage) Return(StringFormat("%d:%s", Floor($nInputSeconds / 60 / 60 / 24), $ElapsedMessage)) EndFunc