WASSIm. Posted May 17, 2014 Posted May 17, 2014 hi guys i have question, how get (year/mother/day - hour/minte/secode) from timestamp ?
Snow-Man Posted May 17, 2014 Posted May 17, 2014 hi guys i have question, how get (year/mother/day - hour/minte/secode) from timestamp ? check this https://wiki.multitheftauto.com/wiki/GetTimestamp
WASSIm. Posted May 17, 2014 Author Posted May 17, 2014 check this https://wiki.multitheftauto.com/wiki/GetTimestamp its (year/mother/day - hour/minte/secode) to timestamp
.:HyPeX:. Posted May 17, 2014 Posted May 17, 2014 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.
WASSIm. Posted May 17, 2014 Author Posted May 17, 2014 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"
.:HyPeX:. Posted May 17, 2014 Posted May 17, 2014 Try this: outputChatBox(os.date("*x", 1302552).." - "..os.date("*X", 1302552))
.:HyPeX:. Posted May 18, 2014 Posted May 18, 2014 "os" functions are disabled in MTA. Why? they're a lua library..
Castillo Posted May 18, 2014 Posted May 18, 2014 "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.
.:HyPeX:. Posted May 18, 2014 Posted May 18, 2014 Oh well, then wassim you gotta do some hard work to do the reverse of the useful function.
tosfera Posted May 18, 2014 Posted May 18, 2014 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]
MIKI785 Posted May 18, 2014 Posted May 18, 2014 You want to get date from timestamp? Then simply use getRealTime and provide the desired timestamp.
.:HyPeX:. Posted May 18, 2014 Posted May 18, 2014 Oh lol, didnt saw that, getRealTime apparently has the aviability to return from a place in time
pa3ck Posted November 24, 2014 Posted November 24, 2014 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?
Sasu Posted November 24, 2014 Posted November 24, 2014 You want to get date from timestamp? Then simply use getRealTime and provide the desired timestamp.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now