A binary clock in PHP

There are some odd functions hidden in PHP. One of them is the decbin function, which makes it easy to convert between decimal and binary numbers.

If you’re bore don a rain day, you could use this function to make a simple binary clock, here’s a few lines to get you started:

echo "Hours: ".decbin(date("H"))."<br>";
echo " Minutes:".decbin(date("i"))."<br>";
echo " Seconds:".decbin(date("s"));

See the binary clock output (and the source of the page).

  • ACJ

    Why would you concatenate with an empty string on line 1? Also, there is a syntax error on line 2.

  • The errors was due to wordpress’ visual editor making a mess of things. The code should now show properly and reflect the source-file version.