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.

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

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" 
  
  

Omerta Roleplay

Posted

Try this:

  
outputChatBox(os.date("*x", 1302552).." - "..os.date("*X", 1302552)) 
  

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

Posted

"os" functions are disabled in MTA.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
"os" functions are disabled in MTA.

Why? they're a lua library..

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

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.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Oh well, then wassim you gotta do some hard work to do the reverse of the useful function.

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

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]

logo-small.png?v=3 tiny-sapdfr.png

 

If you want to contact me directly concerning Advanced-Gaming, please contact me at [email protected]

Posted

Oh lol, didnt saw that, getRealTime apparently has the aviability to return from a place in time :D

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

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