将英国式日期和时间转换为UNIX时间戳(PHP> 5.3)

It is worth mentioning I'm using PHP 5.2 so can't use the DateTime class.

I have the following code:

$date_begin = mysql_real_escape_string($_POST['dateBegin']);
$date_end   = mysql_real_escape_string($_POST['dateEnd']);

Imagine they are now

$date_begin = "28/02/2015";
$date_end   = "22:00:00";

How can I convert this into a php/unix timestamp?

Thanks

If you flip the month and day values you can use strtotime.

$date_begin = preg_replace('~(\d+)/(\d+)/(\d+)~', "$2/$1/$3", "28/02/2015");
$date_end   = "22:00:00";
echo strtotime($date_begin . ' ' . $date_end);