How can I force the date format to output:
12/12/2012, 1/10/2012, 1/5/2012
instead of
12/12/2012, 01/10/2012, 01/05/2012?
My code is the following:
$adatefrom = date_create($_POST['datefrom']);
$adateto = date_create($_POST['adateto']);
$adatefrom = date_format($adatefrom, 'd/m/Y');
$adateto = date_format($adateto, 'd/m/Y');
Please do note that I have to format the date AFTER posting it.
Have a look at the PHP built in
datefunction hereYou will find that your solution is as simple as this:
The key things to note are the characters used in the first parameter.
jrepresents the day without leading zerosnrepresents the month without leading zerosThere are many other options you have, just have a read through the documentation.
Please note that a simple search of ‘PHP date’ on Google would have found this solution for you