Game Development Community

getRealTime() --> how can i calculate the real time?

by Toni Weidstätter · in Torque Game Builder · 06/14/2011 (2:35 pm) · 6 replies

ok, i found this:
Purpose
Use the getRealTime function to get the computer time in milliseconds.

when i start the game at 11:29 p.m. getRealTime() shows me 21319375
so that means 21319 seconds
and that means 355 minutes
and that means 5.9 h --> which would be something like 05:54 a.m.

what am i doing wrong in calculatng the time?

thx for help !

#1
06/17/2011 (2:23 am)
anyone?
#2
06/17/2011 (7:37 am)
You actually bring up a good point.

Ok, here is the thing. Basically the getRealTime function isn't the real world time as far as I can tell looking through the code. It is only the time that has elapsed since the system has booted in milliseconds.

Here is why:

getRealTime only calls Platform::getRealMilliseconds()
Platform::getRealMilliseconds() only calls the function GetTickCount() in windows.

the GetTickCount function in windows, only returns the time that has elapsed since system boot in milliseconds.

I didn't check the Platform class further for other platforms.

As far as I know, if you want the actual real world time, you will have to write a console function, to do so and recompile the engine.

I don't see anywhere, any console function to actually give you the correct system time in a real world time (either in milliseconds or a string) but there are functions in the Platform class that deal w/ it. So it should require minimal effort to do.

Do you have a source license to T2D/TGB? I don't see it on your profile. I can write a resource on TDN, to walk you through it, but it will require that you have a source code license to the engine.
#3
06/19/2011 (1:19 pm)
hi & thx!

i have the bought "Torque 2D" (99$)
is that what is needed?

one question, i've also read that it's possible to use c++ code.
(because you can get the system-time with a c++ command)

how can i use c++ commands with torque? (to get the system-time)

greetings!
#4
06/19/2011 (2:54 pm)
Working on the resource right now. Will update this comment, when finsihed.

[EDIT]Completed, resource. Information follows[/EDIT]

Here is the main resources page for T2D/TGB on TDN:
tdn.garagegames.com/wiki/TGB/Resources

Here is the resource page for this change specifically:
tdn.garagegames.com/wiki/TGB/Resources/Real_World_Time
#5
06/20/2011 (12:44 am)
thank you very, very, very much!
i will try that asap!

do i need to upgrade my torque to the last version or something like that?
or should it also work with my version?
#6
06/20/2011 (2:15 am)
aaah. yeah probably best to update to v1.7.5 since that's the version that was used.