<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Hexon</id>
	<title>Multi Theft Auto: Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Hexon"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/wiki/Special:Contributions/Hexon"/>
	<updated>2026-05-22T02:46:18Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetRealTime&amp;diff=61002</id>
		<title>GetRealTime</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetRealTime&amp;diff=61002"/>
		<updated>2018-12-03T09:42:29Z</updated>

		<summary type="html">&lt;p&gt;Hexon: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server client function}}&lt;br /&gt;
This function gets the server or client (if used client sided it returns time as set on client's computer) real time and returns it in a table. If you want to get the in-game time (shown on GTA's clock) use [[getTime]].&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table getRealTime( [ int seconds = current, bool localTime = true ] )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
*'''seconds:''' A count in seconds from the year 1970.  Useful for storing points in time, or for retrieving time information for [[getBanTime]]. The valid range of this argument is 0 to 32,000,000,000&lt;br /&gt;
{{New feature/item|3.0141|1.4.1|6976|&lt;br /&gt;
*'''localTime:''' Set to ''true'' to adjust for the locally set timezone.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a ''table'' of substrings with different time format or ''false'' if the '''seconds''' argument is out of range.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;2&amp;quot; cellpadding=&amp;quot;2&amp;quot; cellspacing=&amp;quot;0&amp;quot; style=&amp;quot;margin: 1em 1em 1em 0; background: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse; font-size: 95%;&amp;quot;&lt;br /&gt;
|'''Member'''&lt;br /&gt;
|'''Meaning'''&lt;br /&gt;
|'''Range'''&lt;br /&gt;
|-&lt;br /&gt;
|second&lt;br /&gt;
|seconds after the minute&lt;br /&gt;
|0-61*&lt;br /&gt;
|-&lt;br /&gt;
|minute&lt;br /&gt;
|minutes after the hour&lt;br /&gt;
|0-59&lt;br /&gt;
|-&lt;br /&gt;
|hour&lt;br /&gt;
|hours since midnight&lt;br /&gt;
|0-23&lt;br /&gt;
|-&lt;br /&gt;
|monthday&lt;br /&gt;
|day of the month&lt;br /&gt;
|1-31&lt;br /&gt;
|-&lt;br /&gt;
|month&lt;br /&gt;
|months since January&lt;br /&gt;
|0-11&lt;br /&gt;
|-&lt;br /&gt;
|year&lt;br /&gt;
|years since 1900&lt;br /&gt;
|-&lt;br /&gt;
|weekday&lt;br /&gt;
|days since Sunday&lt;br /&gt;
|0-6&lt;br /&gt;
|-&lt;br /&gt;
|yearday&lt;br /&gt;
|days since January 1&lt;br /&gt;
|0-365&lt;br /&gt;
|-&lt;br /&gt;
|isdst&lt;br /&gt;
|Daylight Saving Time flag&lt;br /&gt;
|-&lt;br /&gt;
|timestamp&lt;br /&gt;
|seconds since 1970 (Ignoring set timezone)&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
* ''second'' is generally 0-59. Extra range to accommodate for leap seconds in certain systems.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example adds 'showtime' like the default MTA 'time' command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function showtime ()&lt;br /&gt;
	local time = getRealTime()&lt;br /&gt;
	local hours = time.hour&lt;br /&gt;
	local minutes = time.minute&lt;br /&gt;
	local seconds = time.second&lt;br /&gt;
	-- Make sure to add a 0 to the front of single digits.&lt;br /&gt;
	if (hours &amp;lt; 10) then&lt;br /&gt;
		hours = &amp;quot;0&amp;quot;..hours&lt;br /&gt;
	end&lt;br /&gt;
	if (minutes &amp;lt; 10) then&lt;br /&gt;
		minutes = &amp;quot;0&amp;quot;..minutes&lt;br /&gt;
	end&lt;br /&gt;
	if (seconds &amp;lt; 10) then&lt;br /&gt;
		seconds = &amp;quot;0&amp;quot;..seconds&lt;br /&gt;
	end&lt;br /&gt;
	outputChatBox ( &amp;quot;Local Time: &amp;quot;..hours..&amp;quot;:&amp;quot;..minutes..&amp;quot;:&amp;quot;..seconds )&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;showtime&amp;quot;, showtime)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example with year, month, monthday using string.format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function showtime ()&lt;br /&gt;
	local time = getRealTime()&lt;br /&gt;
	local hours = time.hour&lt;br /&gt;
	local minutes = time.minute&lt;br /&gt;
	local seconds = time.second&lt;br /&gt;
&lt;br /&gt;
        local monthday = time.monthday&lt;br /&gt;
	local month = time.month&lt;br /&gt;
	local year = time.year&lt;br /&gt;
&lt;br /&gt;
        local formattedTime = string.format(&amp;quot;%04d-%02d-%02d %02d:%02d:%02d&amp;quot;, year, month + 1, monthday, hours, minutes, seconds)&lt;br /&gt;
	outputChatBox ( &amp;quot;Local Time: &amp;quot;.. formattedTime )&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;showtime&amp;quot;, showtime)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Changelog==&lt;br /&gt;
{{ChangelogHeader}}&lt;br /&gt;
{{ChangelogItem|1.4.0-9.06976|Added localTime argument}}&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Utility functions}}&lt;br /&gt;
[[ru:getRealTime]]&lt;/div&gt;</summary>
		<author><name>Hexon</name></author>
	</entry>
</feed>