Skip to main content

Time::getPosixTime

Client-side function

JavaScript​

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