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

System hour in CC

Started by TNTeener, 18 December 2012 - 09:42 PM
TNTeener #1
Posted 18 December 2012 - 10:42 PM
Can I program coomand, so os.clock() change while system hour change, and os.clock() is same as system hour?
AfterLifeLochie #2
Posted 18 December 2012 - 11:54 PM
Moved to the Ask a Pro section - it's best to ask questions like this over there, and not in General.
remiX #3
Posted 19 December 2012 - 12:36 AM
Are you asking if you can get the time of your local computer (Real life and not MC time)?
TNTeener #4
Posted 19 December 2012 - 01:14 AM
I can get Real Life hour (my real computer time) in cc computer?
KaoS #5
Posted 19 December 2012 - 01:58 AM
nope, the only way to do that is to use the http interface to access the internet and get the time there
remiX #6
Posted 19 December 2012 - 03:39 AM
Yeah you would have to connect to a php website or something. I asked the same question a while back, too.
Orwell #7
Posted 19 December 2012 - 04:52 AM
Indeed, easiest way is to sign up at 000webhost.com or any other hosting service and creating a file 'time.php' with simple content like this:

<?php
  date_default_timezone_set('UTC'); // use correct timezone
  echo date('h:i:s A', time()); // gives something like '05:12:54 PM'
?>

And in Lua something like:

local content = http.get("http://www.example/com/time.php")
local time = (content~=nil) and content.readAll() or "time server couldn't be reached"