将日期格式更改为php中的数字

Mas*_*osc -3 php format

请问,我如何在php中更改日期格式

从像2012-12-14 08:40:26这样的东西

格式化数字,如28124629523

Joh*_*nde 5

仅供参考,您正在寻找的是一个Unix时间戳

使用 strtotime()

echo strtotime('2012-12-14 08:40:26');
Run Code Online (Sandbox Code Playgroud)

要么 DateTime

$datetime = new DateTime('2012-12-14 08:40:26');
echo $datetime->getTimestamp();
Run Code Online (Sandbox Code Playgroud)