Hey guys does anyone know a code that reads the time of a computer? Not the minecraft computer, computer in real life for real life time.
Thanks
0
[LUA][Code wanted]Real Time
Started by remiX, Oct 07 2012 04:39 PM
4 replies to this topic
#1
Posted 07 October 2012 - 04:39 PM
#2
Posted 07 October 2012 - 05:27 PM
You can look around on the forums. There's at least one program that fetches the real time from a web server. There's no other way of getting the real time.
#5
Posted 07 October 2012 - 07:39 PM
You need a webspace with php. On this webspace you put this Code:
In the config of Computercraft you need to have the http api enabled.
With http api enabled you can receive the current time with
http.get("http://your-domain/your-file.php?timezone=TIMEZONE&format=FORMAT").readAll()
replace TIMEZONE with your timezone (ECT, GMT, UTC, ...)
and FORMAT with pattern you want to fit the time into (for example Y-m-d%20H:i:s gives you something like 2012-10-07 21:27:31 , replace your spaces with %20)
<?php if(empty($_GET)) { echo time(); } else{ if(!empty($_GET["timezone"])) { date_default_timezone_set($_GET["timezone"]); } else{ date_default_timezone_set('UTC'); } if(!empty($_GET["format"])) { echo date($_GET["format"]); } else{ echo date(DATE_RFC822); } } ?>
In the config of Computercraft you need to have the http api enabled.
With http api enabled you can receive the current time with
http.get("http://your-domain/your-file.php?timezone=TIMEZONE&format=FORMAT").readAll()
replace TIMEZONE with your timezone (ECT, GMT, UTC, ...)
and FORMAT with pattern you want to fit the time into (for example Y-m-d%20H:i:s gives you something like 2012-10-07 21:27:31 , replace your spaces with %20)
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users