What seemed to be a fairly standard date conversion is giving me unusual results. I want to get $pay_date into the 'j/d/Y' format, but can only get the correct date if the format is 'Y-m-d'.
Here's my code:
$payment = '2014-09-09';
$pay_date = strtotime("+1 month", strtotime($payment) );
$converter = date('j/d/Y', $pay_date );
echo $converter;
result: 9/09/2014 (should be 10/09/2014)
If I keep these variables, but change $converter to this format:
$converter = date('Y-m-d', $pay_date );
the result is correct - 2014-10-09
I also tried this:
$convert2 = DateTime::createFromFormat('Y-m-d', $pay_date)->format('j/d/Y');
echo $convert2;
result: 9/09/2014
but:
$convert2 = DateTime::createFromFormat('Y-m-d', $pay_date)->format('Y-m-d');
echo $convert2;
gives me the correct result: 2014-10-09