'Why is my date wrong with Carbon::createFromFormat()?
When I create the Carbon object from an existing string, it is making a completely wrong date out of it.
$dateString = "2022-04-01 21:24:00";
$carbon = Carbon::createFromFormat("Y-m-d H:i:s", $dateString);
echo $carbon->format("Y-m-d H:i:s");
and this outputs:
2023-12-01 21:12:00
Totally lost here. This doesn't make sense.
*Edit: Nevermind. I am an idiot and my format in the real code was "Y-m-d H:m:s"
Solution 1:[1]
I think that the code that you post it's not what you are using it seems month is using minutes
so 24 as month become 12 of the next year
probably you are using "Y-m-d H:m:s" instead of "Y-m-d H:i:s"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
