GetRealTime: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (GetCTime moved to GetRealTime: Better name :))
No edit summary
Line 14: Line 14:
|'''Range'''
|'''Range'''
|-
|-
|tm_sec
|seconds
|seconds after the minute
|seconds after the minute
|0-61*
|0-61*
|-
|-
|tm_min
|minutes
|minutes after the hour
|minutes after the hour
|0-59
|0-59
|-
|-
|tm_hour
|hours
|hours since midnight
|hours since midnight
|0-23
|0-23
|-
|-
|tm_mday
|monthday
|day of the month
|day of the month
|1-31
|1-31
|-
|-
|tm_mon
|month
|months since January
|months since January
|0-11
|0-11
|-
|-
|tm_year
|year
|years since 1900
|years since 1900
|-
|-
|tm_wday
|weekday
|days since Sunday
|days since Sunday
|0-6
|0-6
|-
|-
|tm_yday
|yearday
|days since January 1
|days since January 1
|0-365
|0-365
|-
|-
|tm_isdst
|isdst
|Daylight Saving Time flag
|Daylight Saving Time flag
|-
|-

Revision as of 23:25, 17 December 2007

This function gets the real server time and returns it in a table

Syntax

table getCTime()

Returns

Returns a table of substrings with different time format, false otherwise.

Member Meaning Range
seconds seconds after the minute 0-61*
minutes minutes after the hour 0-59
hours hours since midnight 0-23
monthday day of the month 1-31
month months since January 0-11
year years since 1900
weekday days since Sunday 0-6
yearday days since January 1 0-365
isdst Daylight Saving Time flag
  • tm_sec is generally 0-59. Extra range to accommodate for leap seconds in certain systems.

Example

This example outputs local time (server or client, where ever it was triggered) as hours and minutes

function showtime ()
	local time = getCTime()
	local hours = time.tm_hour
	local minutes = time.tm_min
	outputChatBox ( "Local Time: "..hours..":"..minutes )
end

See Also

Shared