- Home /
How to find time in milliseconds?
How can I find time in milliseconds? I would like a float value, not an int.
Thanks
EDIT: By time in milliseconds, I mean how many milliseconds have passed.
Answer by Berenger · Feb 18, 2012 at 08:08 PM
Time.time * 1000;
Er, no. Time.time is a float value in seconds, Time.time*1000 is in milliseconds. Not sure what else you want...milliseconds don't go up "slowly", since there are 1000 of them in a second.
You want to read the value of time in millisecond right ? If you want your game speed to be slowed 1000 times, that's something else (timeScale)(Times homonymous in english are a bit confusing !)
Oh sorry, .ToString() made it seem that way. Im going for something like 10.52 seconds to display.
How could I do that?
It's nice if you don't delete your comments, cause it makes those of us who replied look silly. ;) Time.time.ToString("f2")
However that's time in seconds, not milliseconds.
Answer by HeavyE · Mar 30, 2016 at 05:41 AM
To find the time that has passed, you can use Time.deltaTime in your Update() method.
Time.deltaTime gives you the time that has passed in seconds. To get the milliseconds, simply multiply by 1000.
float timeChangeInMillis = Time.deltaTime * 1000;
Time.deltaTime gives you the time that has passed since the last frame drawn.