Squirrel/Server/Functions/Utils/GetTime
From Liberty Unleashed Wiki
(Difference between revisions)
(→Notes) |
m |
||
Line 1: | Line 1: | ||
{{Squirrel/Title|GetTime}} | {{Squirrel/Title|GetTime}} | ||
+ | {{Squirrel/Deprecated|It is recommended that Squirrel's [http://squirrel-lang.org/doc/sqstdlib3.html#d0e1913 system library function], time() be used instead.}} | ||
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. | 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. | ||
Line 21: | Line 22: | ||
MessagePlayer( "Did you know, that " + floor( GetTime() / 86400 ) + " days have elapsed since January 1, 1970?", player ); | MessagePlayer( "Did you know, that " + floor( GetTime() / 86400 ) + " days have elapsed since January 1, 1970?", player ); | ||
} | } | ||
+ | |||
+ | return 1; | ||
} | } | ||
</code> | </code> | ||
Line 26: | Line 29: | ||
=== Notes === | === Notes === | ||
− | The function [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] and call [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] were used | + | The function [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] and call [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] were used in this example. More info about them in corresponding pages. |
− | + | ||
− | + | ||
== Related Functions == | == Related Functions == | ||
{{Squirrel/Server/Functions/Utils}} | {{Squirrel/Server/Functions/Utils}} |
Latest revision as of 14:22, 29 April 2011
Note: This function is deprecated. Its use is discouraged as it may be removed in a future update. It is recommended that Squirrel's system library function, time() be used instead.
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.
[edit] Syntax
int GetTime()
[edit] Arguments
- none
[edit] 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 ); } return 1; }
[edit] Notes
The function MessagePlayer and call onPlayerCommand were used in this example. More info about them in corresponding pages.