Jump to content
Sign in to follow this  
Alek

time to days, hours,min and sec

Recommended Posts

Alek

turns a timestamp in ms to days, hours,minuts and seconds.

i use it to see for how long my scripts has bin runing.

the function.

CODE
Func timestamptotime($s_time)
    Local $s_days = 0
    Local $s_hour = 0
    Local $s_min = 0
    $s_time = $s_time/1000
    $x = 0
    Do 
        $x = $x +1
        if $s_time > 86399*$x and $s_time < 86399*($x+1) Then
            $s_days = $x
            $s_time = $s_time-86400*$x
            ExitLoop
        EndIf
    Until $x = 100
    $x = 0
    Do
        $x = $x+1
        if $s_time > 3599*$x and $s_time < 3599*($x+1) then 
            $s_hour = $x
            $s_time = $s_time-3600*$x
            ExitLoop
        EndIf
    Until $x = 25
    $x = 0
    Do
        $x = $x+1
        if $s_time > 59*$x and $s_time < 59*($x+1) then 
            $s_min = $x
            $s_time = $s_time-59*$x
            ExitLoop
        EndIf
    Until  $x = 61
    $s_time = Round($s_time,0)
    if $s_days < 10 then $s_days = "0" & $s_days
    if $s_hour < 10 then $s_hour =  "0" & $s_hour
    if $s_min < 10 then $s_min=  "0" & $s_min
    if $s_time < 10 then $s_time = "0" & $s_time
    Return $s_days & "-" & $s_hour & ";" & $s_min & ";" & $s_time
EndFunc
oÝ÷ Û÷(uæèÅìZ¥r^nZºÚ"µÍÌÍÝ[YH[Y[]

BÝZXÜX]J  ][ÝÉ][ÝË
ÌKLKLK
BÌÍÛX[HÕRPÝÜX]SX[
    ][ÝÉ][ÝËËË
MKLL
BÌÍÛÛ[YHH   ][ÝÉ][ÝÂÕRTÙ]Ý]J
BÚ[HBIÌÍÝ[YHH[YÝ[Ý[YJ[YY  ÌÍÝ[YJBZY    ÌÍÝ[YH   ÉÝÈ  ÌÍÛÛ[YH[BQÕRPÝÙ]]J   ÌÍÛX[    ÌÍÝ[YJBBIÌÍÛÛ[YHH    ÌÍÝ[YBQ[YÛY
L
BÑ[[È[YÝ[Ý[YJ   ÌÍÜ×Ý[YJBSØØ[    ÌÍÜ×Ù^ÈHSØØ[    ÌÍÜ×ÚÝHSØØ[ ÌÍÜ×ÛZ[HIÌÍÜ×Ý[YHH    ÌÍÜ×Ý[YKÌLIÌÍÞHQÈBIÌÍÞH    ÌÍÞ
ÌBBZY  ÌÍÜ×Ý[YH   ÝÈ
ÎNJÌÍÞ[ ÌÍÜ×Ý[YH   È
ÎNJ    ÌÍÞ
ÌJH[BBIÌÍÜ×Ù^ÈH  ÌÍÞBBIÌÍÜ×Ý[YHH ÌÍÜ×Ý[YKN

ÌÍÞBBQ^]ÛÜBQ[YU[[  ÌÍÞHLIÌÍÞHQÂBIÌÍÞH    ÌÍÞ
ÌBBZY  ÌÍÜ×Ý[YH   ÝÈÍNNJÌÍÞ[    ÌÍÜ×Ý[YH   ÈÍNNJ ÌÍÞ
ÌJH[BBIÌÍÜ×ÚÝH   ÌÍÞBBIÌÍÜ×Ý[YHH ÌÍÜ×Ý[YKLÍ
ÌÍÞBBQ^]ÛÜBQ[YU[[  ÌÍÞHBIÌÍÞHQÂBIÌÍÞH    ÌÍÞ
ÌBBZY  ÌÍÜ×Ý[YH   ÝÈ
NJÌÍÞ[   ÌÍÜ×Ý[YH   È
NJ  ÌÍÞ
ÌJH[BBIÌÍÜ×ÛZ[H   ÌÍÞBBIÌÍÜ×Ý[YHH ÌÍÜ×Ý[YKMNJÌÍÞBBQ^]ÛÜBQ[YU[[  ÌÍÞH
BIÌÍÜ×Ý[YHHÝ[
    ÌÍÜ×Ý[YK
BZY ÌÍÜ×Ù^È   ÈL[    ÌÍÜ×Ù^ÈH  ][ÝÌ  ][ÝÈ  [È ÌÍÜ×Ù^ÂZY ÌÍÜ×ÚÝ    ÈL[    ÌÍÜ×ÚÝH   ][ÝÌ  ][ÝÈ  [È ÌÍÜ×ÚÝZY  ÌÍÜ×ÛZ[    ÈL[    ÌÍÜ×ÛZ[H   ][ÝÌ  ][ÝÈ  [È ÌÍÜ×ÛZ[ZY  ÌÍÜ×Ý[YH   ÈL[    ÌÍÜ×Ý[YHH  ][ÝÌ  ][ÝÈ  [È ÌÍÜ×Ý[YBT] ÌÍÜ×Ù^È   [È ][ÝËI][ÝÈ   [È ÌÍÜ×ÚÝ    [È ][ÝÎÉ][ÝÈ  [È ÌÍÜ×ÛZ[    [È ][ÝÎÉ][ÝÈ  [È ÌÍÜ×Ý[YB[[Â
Edited by Alek

[font="Impact"]Never fear, I is here.[/font]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.