Time::getPosixTime: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
No edit summary
 
Line 1: Line 1:
Gets system time as year, month, day, hour, minute and second.<br><br>Example usage:<br><br> int year;<br> int month;<br> int day;<br> int hour;<br> int minute;<br> int second;<br><br> TIME::GET_POSIX_TIME(&amp;year, &amp;month, &amp;day, &amp;hour, &amp;minute, &amp;second);<br>
{{ClientsideJsFunction}}
==Syntax==
{{JSContainer|
<syntaxhighlight lang="javascript">mp.game.time.getPosixTime(year, month, day, hour, minute, second);</syntaxhighlight>
 
=== Required Arguments ===
=== Summary ===
*'''year:''' int
Retrieves the POSIX system time, returning an object with year, month, day, hour, minute, and second based on the system clock.
*'''month:''' int
 
*'''day:''' int
=== Syntax ===
*'''hour:''' int
*'''minute:''' int
*'''second:''' int
===Return value===
*'''object:''' year, month, day, hour, minute, second
==Example==
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
// todo
mp.game.time.getPosixTime(year, month, day, hour, minute, second);
</syntaxhighlight>
</syntaxhighlight>
==See also==
 
{{Time_s_function_c}}
=== 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



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}`);


See Also