Trivial Functions: Date As Color
I was noodling around during lunch with a way to express a date as a hexidecimal color value. Thought it might be an interesting way to color code the blog post titles. In the end I didn’t like the way it looked but thought I’d share the code with all of you in case you could use it for something.
function makeHexFromDate($itemDate) {
$hexdate = dechex($itemDate);
$hexlength = strlen($hexdate);
if ($hexlength < 6) {
for ($i = 1; $i <= (6 - $hexlength); $i++) {
$hexdate .= "0";
}
}
echo "#".$hexdate;
}
It’s not the most optimal, but then again, I did only spend an hour on it. It’s a start. If you have suggestions for improvements, I’d love to hear them.

Jump to comment form | comments rss [?] | trackback uri [?]