PHP - Write program to use the printf() function

Requirements

Write program to use the printf() function

Write a single line of code that takes a month (from 1 to 12), a day (from 1 to 31), and a four-digit year, and displays the resulting date, formatted in mm/dd/yyyy format.

Add a zero in front of the month or day if it's less than 10.

Demo

<?php
    printf("%02d/%02d/%d", 3, 24, 2008); // Displays "03/24/2008"
?>

Result

Related Topic