Chad Cunningham bio photo

Chad Cunningham

Not a rockstar or a ninja.

Email Twitter Github Stackoverflow

A while back I discovered the excellent stamp gem for ruby. It gives you a fantastic way to format dates by simply supplying an example string, rather than having to remember the various formatting parameters to traditional date formatting functions. I’ve found this so useful that I had to create a PHP version, which I also lamely called stamp.

Stamp provides a simple method to format dates. For example:

stamp("January 1, 2012 at 4:53PM", time()); ?>

By supplying an example date string, you never again have to remember the difference between d, D, j, etc in php’s date formatting. Even better, the stamp method can be passed a timestamp, a DateTime object or a string (which will be passed through strtotime).

Check out stamp at github

There is still plenty of work to do, but it should be usable now. In the near future I’ll be buffing up the test suite and trying to make it as performant as possible.