Jump to content

timestamp


WASSIm.

Recommended Posts

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.

Link to comment
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" 
  
  

Link to comment

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]

Link to comment
  • 6 months later...

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...