Time::getPosixTime: Difference between revisions
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
{{ClientsideJsFunction}} | |||
{{JSContainer| | |||
=== | === Summary === | ||
Retrieves the POSIX system time, returning an object with year, month, day, hour, minute, and second based on the system clock. | |||
=== Syntax === | |||
== | |||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
mp.game.time.getPosixTime(year, month, day, hour, minute, second); | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See | |||
{{ | === Required Parameters === | ||
* '''year:''' {{RageType|int}} - The current year from the POSIX time. | |||
* '''month:''' {{RageType|int}} - The current month from the POSIX time. | |||
* '''day:''' {{RageType|int}} - The current day from the POSIX time. | |||
* '''hour:''' {{RageType|int}} - The current hour from the POSIX time. | |||
* '''minute:''' {{RageType|int}} - The current minute from the POSIX time. | |||
* '''second:''' {{RageType|int}} - The current second from the POSIX time. | |||
=== Return Value === | |||
* '''Object:''' Contains: | |||
* `year` | |||
* `month` | |||
* `day` | |||
* `hour` | |||
* `minute` | |||
* `second` | |||
=== Example === | |||
This example gets the current POSIX time and displays it in the in-game chat: | |||
<syntaxhighlight lang="javascript"> | |||
const posixTime = mp.game.time.getPosixTime(); | |||
mp.gui.chat.push(`POSIX Time: ${posixTime.year}-${posixTime.month}-${posixTime.day} ${posixTime.hour}:${posixTime.minute}:${posixTime.second}`); | |||
</syntaxhighlight> | |||
}} | |||
== See Also == | |||
{{Time_functions_c}} | |||
[[Category:Clientside API]] | [[Category:Clientside API]] | ||
[[Category:Time API]] | [[Category:Time API]] | ||
[[Category:TODO: Example]] | [[Category:TODO: Example]] | ||
Latest revision as of 12:41, 10 December 2024
Client-Side Function
JavaScript Syntax
Summary
Retrieves the POSIX system time, returning an object with year, month, day, hour, minute, and second based on the system clock.
Syntax
mp.game.time.getPosixTime(year, month, day, hour, minute, second);
Required Parameters
- year: int - The current year from the POSIX time.
- month: int - The current month from the POSIX time.
- day: int - The current day from the POSIX time.
- hour: int - The current hour from the POSIX time.
- minute: int - The current minute from the POSIX time.
- second: int - The current second from the POSIX time.
Return Value
- Object: Contains:
* `year` * `month` * `day` * `hour` * `minute` * `second`
Example
This example gets the current POSIX time and displays it in the in-game chat:
const posixTime = mp.game.time.getPosixTime();
mp.gui.chat.push(`POSIX Time: ${posixTime.year}-${posixTime.month}-${posixTime.day} ${posixTime.hour}:${posixTime.minute}:${posixTime.second}`);