I find a problem related to the date function in php
i want to convert a date '04-08-2016'(mm-dd-yyyy) into a different format '2016-04-08'(yyyy-mm-dd). But it produces the result as '2016-08-04'(yyyy-dd-mm) instead of '2016-04-08'(yyyy-mm-dd).
my code is
$date = '04-08-2016';
echo date('Y-m-d',strtotime($date));
If i place '/' in place of '-' then it is working fine.
Can anyone tell me why this is happening?
createFromformat()method that allows you to tell PHP what format is being used for a date, eliminating any ambiguity or guessing"/"or"-".... there is nothing wrong with strtotime(), just with your lack of knowledge, and that lack willl be eliminated if you read the PHP docs link