Time::getLocalTime: Difference between revisions
(yay) |
No edit summary |
||
| (One intermediate revision by one other user not shown) | |||
| Line 1: | Line 1: | ||
{{ClientsideJsFunction}} | |||
{{JSContainer| | |||
=== Summary === | |||
Retrieves the local system time, returning an object containing year, month, day, hour, minute, and second. | |||
=== Syntax === | |||
=== | |||
== | |||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
mp.game.time.getLocalTime(year, month, day, hour, minute, second); | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See | |||
{{ | === 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 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}`);