Hello I hope everyone’s Ok and I hope I0m mistaken but I use a little code to validate dates in order to check that the client input is a valid and real date
I use
function validateDate($date, $format="Y-m-d H:i:s"){
$d = DateTime::createFromFormat($format, $date);
return $d && $d->format($format) == $date;
}
Everything was working fine until this late night, as I was checking some code and I was getting some of my own custom error messages saying that the date was invalid. So I started echoing some data with the following code
$date = "2023-04-02 02:48:27";
var_dump($date);
$d = DateTime::createFromFormat("Y-m-d H:i:s", $date);
var_dump($d->format("Y-m-d H:i:s"));
And the result shecked me:
string '2023-04-02 02:48:27' (length=19)
string '2023-04-02 03:48:27' (length=19)
The weird thing is that it only happens when the hour is 02, if i type another hour this doesn’t happen.
Do you think this is a bug or am I doing something wrong?
I’m using php 7.4, I’m about to upload it but this was weird so you can know!