I am trying to format dates from a UK format to YYYY-MM-DD an am getting weird results.
The code I am using is:
echo "<br>".$_GET['trans_date'];
echo "<br>".$_GET['next_payment'];
echo "<br>".$_GET['payment_date'];
echo "<br><br>".date("Y-m-d", strtotime($_GET['trans_date']));
echo "<br>".date("Y-m-d", strtotime($_GET['next_payment']));
echo "<br>".date("Y-m-d", strtotime($_GET['payment_date']));
And I get the following results:
19/05/2016
01/06/2016
19/05/2016
1970-01-01
2016-01-06
1970-01-01
I am expecting the following results:
19/05/2016
01/06/2016
19/05/2016
2016-05-19
2016-01-01
2016-05-19
Can anyone what's going wrong?
Thanks,
John
/in a date with axx/xx/xxxxstructure, it treats it as US format (mm/dd/yyyy).... either change the/to-before usingstrtotime()or use DateTime::createFromFormat() to create a DateTime object