Squirrel/Server/Functions/Utils/GetTime
From Liberty Unleashed Wiki
(Difference between revisions)
(→Notes) |
|||
Line 27: | Line 27: | ||
The function [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] and call [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] were used in in this example. More info about them in corresponding pages. | The function [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] and call [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] were used in in this example. More info about them in corresponding pages. | ||
+ | |||
+ | It is recommended that Squirrel's [http://squirrel-lang.org/doc/sqstdlib3.html#d0e1913 system function], time() be used instead as this function may become obsolete in future versions. | ||
== Related Functions == | == Related Functions == | ||
{{Squirrel/Server/Functions/Utils}} | {{Squirrel/Server/Functions/Utils}} |
Revision as of 18:50, 27 April 2011
This function returns the number of seconds elapsed since January 1, 1970 (also known as the unix time). This function is useful for measuring longer time intervals.
Syntax
int GetTime()
Arguments
- none
Example
This example tells the player how many days have elapsed since January 1, 1970, when they type '/days'
function onPlayerCommand( player, cmd, text ) { if ( cmd == "days" ) { MessagePlayer( "Did you know, that " + floor( GetTime() / 86400 ) + " days have elapsed since January 1, 1970?", player ); } }
Notes
The function MessagePlayer and call onPlayerCommand were used in in this example. More info about them in corresponding pages.
It is recommended that Squirrel's system function, time() be used instead as this function may become obsolete in future versions.