PHP将日期转换为unix时间戳


PHP Date conversion to unix-timestamp

如何将2014-11-03 17:01:37转换为Unix时间戳?有什么方法我可以用吗。

您可以创建一个DateTime对象:

$time = new DateTime("2014-11-03 17:01:37");
$time->getTimestamp();

使用-strtotime()

$date = "2014-11-03 17:01:37";
echo strtotime($date);
strtotime('2014-11-03 17:01:37')

PHP有一个用于此目的的函数strtotime

echo strtotime("2014-11-03 17:01:37");