0

I've been trying to read the PHP documentation for my answer.

Why does PHP recognize that 04/06/2020 is in MM/DD/YYYY format and not DD/MM/YYYY?

Looking at the docs that is because it is simply not an accepted format. With that being the case I suppose there would never be a case where PHP would confuse this format with another?

Is there a way to amend to following so that I could tell strtotime() the input date format (maybe completely unnecessary)?

$date = "04/06/2020";
$newDate = date("Y-m-d", strtotime($date));
FamousAv8er
  • 2,345
  • 2
  • 9
  • 27
  • 1
    Why? Because apparently mostly Americans use MM/DD/YYYY, while Europeans use DD-MM-YYYY (I'm guessing from the [reasoning in the documentation](https://www.php.net/manual/en/function.strtotime.php#refsect1-function.strtotime-notes)). As it mentions, you can try using `DateTime::createFromFormat()` instead. – aynber Apr 13 '20 at 20:34
  • @aynber thank you for the answer and alternative solution. If you put this as an answer I will accept it. – FamousAv8er Apr 13 '20 at 20:37

0 Answers0