Formatting integer (2 printed as 02)

Yep, you can use sprintf:

sprintf("%0.2d", 4)

=> "04"