Time::getPosixTime

From RAGE Multiplayer Wiki
Revision as of 12:41, 10 December 2024 by Shr0x (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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