Noor Noor - 9 days ago 7
PHP Question

php date and strtotime for next year return current year

I have faced a small issue. check the below code

echo date('Y-m-d', strtotime('15 Nov, 2018'));


I was expecting that it will return 2018-11-15 but when i echo the result it returns 2016-11-15,

Can some one tell me what is the issue.
Thanks in advance

Answer

This is because of comma. Following works fine after removing comma:

echo date('Y-m-d', strtotime(str_replace(',','','15 Nov, 2018')));