strtotime() DateTime 类模拟方法

php
2022-08-30 17:07:59

有没有一种类的方法可以像核心PHP函数一样起作用?DateTimestrtotime()

例如strtotime('last monday');


答案 1

那就是:DateTime::__construct

$date = new DateTime('Sunday');

答案 2

由于返回较长的 UNIX 时间戳,因此 DateTime 具有方法 。strtotime()getTimestamp()

$date = new DateTime('2012-01-25 19:44:49.123');
echo $date->getTimestamp();

推荐