public
Last active — forked from bxt/clock.php

  • Download Gist
clock.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#!/usr/bin/php
<?php
// Do not execute this file through a web server...
// inspired by http://stackoverflow.com/questions/3324301/code-golf-digital-clock
// If you trim this down to match the task in this thread you get about 240 bytes
 
$parts=str_split(" | _ |_| _||_ | | . 152600134133620143142100122123677666",3);
 
echo PHP_EOL;
 
while (true) {
echo str_repeat(PHP_EOL,100);
$time=date('H:i:s')." ".sprintf("%3d",round((microtime(true)-time())*1000));
 
//$s="12:34567 89990";
$s=$time;
$l=array();
foreach (str_split($s) as $c) {
if($c==":") $c=10;
if($c==" ") $c=11;
for($i=0;$i<3;$i++){
@$l[$i].=$parts[ $parts[$c+8][$i] ];
}
}
 
echo implode(PHP_EOL,$l);
 
echo PHP_EOL;
usleep(500);
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.