Function to get system time

Posted by Shadoweave on Wed 26 Sep 2007 08:27 PM — 9 posts, 33,790 views.

#0
Hello, I was wondering what is the function that allows you to print the current system time, I want to add the time to my prompt. I have tried searching in the help file for this function, but I haven't found it, perhaps I have missed it.
USA #1
http://www.lua.org/pil/22.1.html
#2
Thanks, but how do I get it to show the time in miliseconds too? I've only managed to get it to show the time in seconds
USA #3
By default, Lua doesn't provide the current system time in milliseconds because that information is (I believe) not ANSI C. I think this would require an addition by Nick to the API extensions.
Sweden #4
In Lua, try using the os.date() function.
USA #5
How do you get milliseconds with that? I might be missing something obvious, but I don't see it in the documentation...
#6
Quote:

In Lua, try using the os.date() function.

I am using that to display the time, it doesn't display milliseconds
I've seen someone using GetInfo (232) and dividing it by 60, but it doesn't work correctly, it displays a minute having more than 60 seconds. Any ideas?
USA #7
Perhaps Lua doesn't support it.

So I tried looking around in other languages. Python doesn't seem to have it either.
http://docs.python.org/lib/module-time.html

You may be able to take the raw time and divide it until you get ms.
Amended on Thu 27 Sep 2007 07:36 PM by Zeno
Australia Forum Administrator #8
GetInfo (232) gives you a high resolution timer, but it isn't directly related to the system time.

I don't think standard C libraries, and therefore Lua, let you get time to less than 1 second resolution.