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.

 
  • You could actually make a half decent usability plugin out of this, Use different colors for each month and then use different shades of that color for each date in the month... Im not sure how popular or effective it would be but hey.. its just an experiment right :)
blog comments powered by Disqus