kkbenj
asked on
PHP Reversing order of MMYY
If I have user input of 0812, I need the variable to be changed to 1208. So my quick attempt to do this is:
$expiry_date=$_POST[abc]; //'1308' YYMM
$backwardsExpiry = sprintf("%02d",substr($_PO ST[abc],3, 2)).sprint f("%02d",s ubstr($_PO ST[abc],0, 2));
print("Expiry = " . $expiry_date."<br>");
print("Backwards = " . $backwardsExpiry."<br>");
The print out is
0812
0208
How do I fill only if it comes back as 8 rather than 08?
$expiry_date=$_POST[abc]; //'1308' YYMM
$backwardsExpiry = sprintf("%02d",substr($_PO
print("Expiry = " . $expiry_date."<br>");
print("Backwards = " . $backwardsExpiry."<br>");
The print out is
0812
0208
How do I fill only if it comes back as 8 rather than 08?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
yes.... a great coder do a silly mistake always...!
ASKER