Boise DatingWinston Salem Dating

Trivial Functions: Date As Color

Filed under Interweb, PHP on 05/08/08

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.

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI


Leave a comment

Alright, the time has come to add your two cents to the matter... awesome. The more the merrier, I say. However, before you go half-cocked and act like a total douchebag on this site, make note that I reserve the right to edit or remove any comments that are abusive or spam-like in nature (although I am fairly lenient). Having said that, I'll leave you to it. Go get 'em, tiger.