Time::getLocalTime: Difference between revisions

From RAGE Multiplayer Wiki
(yay)
No edit summary
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
Gets local 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>or use std::tm struct<br><br>TIME::GET_LOCAL_TIME(&amp;year, &amp;month, &amp;day, &amp;hour, &amp;minute, &amp;second);<br>
{{ClientsideJsFunction}}
==Syntax==
{{JSContainer|
<syntaxhighlight lang="javascript">mp.game.time.getLocalTime(year, month, day, hour, minute, second);</syntaxhighlight>
 
=== Required Arguments ===
=== Summary ===
*'''year:''' int
Retrieves the local system time, returning an object containing year, month, day, hour, minute, and second.
*'''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.getLocalTime(year, month, day, hour, minute, second);
</syntaxhighlight>
</syntaxhighlight>
==See also==
 
{{Time_s_function_c}}
=== Required Parameters ===
* '''year:''' {{RageType|int}} - The current year based on the local system clock.
* '''month:''' {{RageType|int}} - The current month based on the local system clock.
* '''day:''' {{RageType|int}} - The current day based on the local system clock.
* '''hour:''' {{RageType|int}} - The current hour based on the local system clock.
* '''minute:''' {{RageType|int}} - The current minute based on the local system clock.
* '''second:''' {{RageType|int}} - The current second based on the local system clock.
 
=== Return Value ===
* '''Object:''' Contains the following properties:
  * `year`
  * `month`
  * `day`
  * `hour`
  * `minute`
  * `second`
 
=== Example ===
This example retrieves the local system time and displays it in the in-game chat:
<syntaxhighlight lang="javascript">
const localTime = mp.game.time.getLocalTime();
mp.gui.chat.push(`Local Time: ${localTime.year}-${localTime.month}-${localTime.day} ${localTime.hour}:${localTime.minute}:${localTime.second}`);
</syntaxhighlight>
}}
 
== See Also ==
{{Time_functions_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]
[[Category:Time API]]
[[Category:TODO: Example]]
[[Category:TODO: Example]]

Latest revision as of 12:40, 10 December 2024

Client-Side
Function

 JavaScript



JavaScript Syntax


Summary

Retrieves the local system time, returning an object containing year, month, day, hour, minute, and second.

Syntax

mp.game.time.getLocalTime(year, month, day, hour, minute, second);

Required Parameters

  • year: int - The current year based on the local system clock.
  • month: int - The current month based on the local system clock.
  • day: int - The current day based on the local system clock.
  • hour: int - The current hour based on the local system clock.
  • minute: int - The current minute based on the local system clock.
  • second: int - The current second based on the local system clock.

Return Value

  • Object: Contains the following properties:
 * `year`
 * `month`
 * `day`
 * `hour`
 * `minute`
 * `second`

Example

This example retrieves the local system time and displays it in the in-game chat:

const localTime = mp.game.time.getLocalTime();
mp.gui.chat.push(`Local Time: ${localTime.year}-${localTime.month}-${localTime.day} ${localTime.hour}:${localTime.minute}:${localTime.second}`);


See Also