I have this string: "13/10 15:00" and I would like to convert it to timestamp but when I do this:
$timestamp = strtotime("13/10 15:00");
It returns an empty value.
In your code strtotime()
is attempting to convert 13/10
as the tenth day of the 13th month, which returns an error.
If you want to parse a date string with a custom format, it's better to use DateTime::createFromFormat() instead:
$dtime = DateTime::createFromFormat("d/m G:i", "13/10 15:00");
$timestamp = $dtime->getTimestamp();