in reply to
Just a bit off topic...
Correctly speaking, sprintf() and printf() are probably the better solution. But it seems that you're unfamiliar with those and more comfortable concatinating leading zeros. There is absolutely nothing wrong with the way your doing things, there is always more than one way to do things and your way seems just as good as any other.
to answer your question though:
$day = 5; #test variable
$month = 7; #test variable
$day = sprintf("%02d",$day);
$month = sprintf("%02d",$month);