Jump to content
Sign in to follow this  

Can We Do Aritmetic With the Result of TimerInit()

Recommended Posts

The result of TImerInit() is supposed to be millisecond. So i guess it is possible to add/minus value to it. But is this property guaranteed by the development team? Would it be changed in the future to some internal format?

Share this post

Link to post
Share on other sites

TimerInit() returns the number of milliseconds from last system boot. TimerDiff() does the same but substracts the previous amount. Voila! A reliable metric to measure time difference. I don't see why this would change.

Heres an example:

$milliseconds = TimerDiff(0)
$years = Int($milliseconds / 31536000000)
$remainMS = Mod($milliseconds, 31536000000)
$days = Int($remainMS / 86400000)
$remainMS = Mod($milliseconds, 86400000)
$hours = Int($remainMS / 3600000)
$remainMS = Mod($milliseconds, 3600000)
$minutes = Int($remainMS / 60000)
$remainMS = Mod($milliseconds, 60000)
$seconds = Int($remainMS / 1000)
$remainMS = Mod($milliseconds, 1000)

MsgBox(0,"Time since last boot","Years: " & $years & @CRLF & "Days: " & $days & @CRLF & "Hours: " & $hours & @CRLF & "Minutes: " & $minutes & @CRLF & "Seconds: " & $seconds & @CRLF & "Milliseconds: " & Int($remainMS))
Edited by weaponx

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...