This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
columna1's profile picture

unix timestamp

Started by columna1, 07 April 2014 - 12:11 AM
columna1 #1
Posted 07 April 2014 - 02:11 AM
Is there some webservice or something that I can use to get the current unix timestamp? Im making a program that reads/writes files that use these and I would like it to be at least somewhat accurate.
Anavrins #2
Posted 07 April 2014 - 05:25 AM
I use http://www.timeapi.org/utc/now?format=%25s to get the epoch for my programs ;)/>
Edited on 07 April 2014 - 03:25 AM
theoriginalbit #3
Posted 07 April 2014 - 05:39 AM
It seems that you're after something more like a unique value, and since HTML interaction is not always enabled it is better to try and do something local, as such you can do the following.

local function getMinecraftTimestamp()
  return string.format("%d:%d:%d", os.day(), os.time(), os.clock())
end

os.day — Minecraft day
os.time — Minecraft time
os.clock — time in seconds the computer has been running (this may not be the time the program has been running)
columna1 #4
Posted 07 April 2014 - 05:13 PM
I use http://www.timeapi.o...now?format=%25s to get the epoch for my programs ;)/>
Thank you very much for this Anavrins this is perfect