Time (tm.time)
Client side only. In-game clock utilities. Every function reads the GTA world time (hours and minutes), not real time.
Functions
| Call | Returns |
|---|---|
tm.time.get() | hours, minutes (0 to 23, 0 to 59). |
tm.time.get12Hour() | The clock as '03:45 PM'. |
tm.time.getTotalSeconds() | Seconds since in-game midnight, at minute resolution. |
tm.time.isBetween(startHour, endHour) | true when the hour is in [startHour, endHour). A range that wraps midnight works. Equal hours cover the whole day. |
tm.time.isDaytime() | true from 06:00 to 18:00. |
tm.time.isNighttime() | The opposite of isDaytime. |
tm.time.getMinutesUntil(targetHour) | In-game minutes until the clock next reads targetHour:00. 0 when it is exactly that minute now. |
tm.time.hasHourPassed(hour) | true when the in-game hour is hour or later today. |
tm.time.realToGameMinutes(realMinutes) | How many in-game minutes pass during realMinutes real minutes, from the current time scale. |
lua
local hour, minute = tm.time.get()
print(('It is %02d:%02d'):format(hour, minute))
if tm.time.isBetween(22, 4) then
-- late night
end
local gameMinutes = tm.time.realToGameMinutes(5)