Jump to content

timestamp


WASSIm.

Recommended Posts

Posted

Its pretty easy, this should just return the Unix time from just now and outputit into chatbox when pressing F5:

(Then it will just display current time, date and the unix obtained by getRealTime (wich should be same to the first one)

  
function time() 
local time = getRealTime() 
time.month = time.month + 1 
time.year = time.year + 1900 
local unix = getTimestamp(time.year,time.month,time.monthday,time.hour,time.minute,time.second) 
outputChatBox("TimeStamp Unix: "..unix) 
if time.second < 10 then 
time.second = "0"..time.second 
end 
if time.minute < 10 then 
time.minute = "0"..time.minute 
end 
if time.hour < 10 then 
time.hour = "0"..time.hour 
end 
outputChatBox("Real TimeStamp: "..time.timestamp) 
outputChatBox("Time: "..time.hour..":"..time.minute..":"..time.second) 
outputChatBox("Date: "..time.monthday.."/"..time.month.."/"..time.year) 
  
end 
bindKey("F5", "down", time) 
  

Note that they wont be exactly the same, as there's a delay between them in the code.

Posted
Its pretty easy, this should just return the Unix time from just now and outputit into chatbox when pressing F5:

(Then it will just display current time, date and the unix obtained by getRealTime (wich should be same to the first one)

  
function time() 
local time = getRealTime() 
time.month = time.month + 1 
time.year = time.year + 1900 
local unix = getTimestamp(time.year,time.month,time.monthday,time.hour,time.minute,time.second) 
outputChatBox("TimeStamp Unix: "..unix) 
if time.second < 10 then 
time.second = "0"..time.second 
end 
if time.minute < 10 then 
time.minute = "0"..time.minute 
end 
if time.hour < 10 then 
time.hour = "0"..time.hour 
end 
outputChatBox("Real TimeStamp: "..time.timestamp) 
outputChatBox("Time: "..time.hour..":"..time.minute..":"..time.second) 
outputChatBox("Date: "..time.monthday.."/"..time.month.."/"..time.year) 
  
end 
bindKey("F5", "down", time) 
  

Note that they wont be exactly the same, as there's a delay between them in the code.

that not what i want exactly, i want funtion like this

function getTimeDate (timestamp) 
 -- code 
end 
  
outputChatBox(getTimeDate(1302552)) -- return string/show on chat: "2014/5/17 - 22:31:15" 
  
  

Posted
"os" functions are disabled in MTA.

Why? they're a lua library..

They were disabled for security reasons as far as I know, you should ask someone who knows more about the subject.

Posted

As far as I know, the os library has been disabled due the following functions;

os.execute([command]) - Execute an operating system shell command. This is like the C system() function. The system dependent status code is returned.

os.exit(

)[/b] - [i]Calls the C function exit, with an optional code, to terminate the host program. The default value for code is the success code.[/i]

[b]os.remove(filename)[/b] - [i]Deletes the file with the given name. If this function fails, it returns nil, plus a string describing the error.[/i]

[i]source: http://lua-users.org/wiki/OsLibraryTutorial[/i]

  • 6 months later...
Posted

Sorry for bumping this topic, but I'm looking for the same answer, I don't want to open a new topic though. How do you convert a date time from a timestamp?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...