Noor
Noor

Reputation: 45

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

Upvotes: 0

Views: 304

Answers (3)

Martin S
Martin S

Reputation: 428

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

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

Upvotes: 1

Pramitha
Pramitha

Reputation: 1

Remove comma after Nov

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

it will give you the correct result

Upvotes: 0

rahul
rahul

Reputation: 506

try removing the comma : echo date('Y-m-d', strtotime('15 Nov 2018'));

Read more about the supported formats here : strtotime

Upvotes: 0

Related Questions