Magento2 DateTime:createFromFormat 未找到和制动代码

Magento2 DateTime:createFromFormat it is not found and brake code

我在模块中使用以下行

    $firstNextMonth = date("Y-m-d H:i:s", strtotime(date('m', strtotime('+1 month')).'/01/'.date('Y').' 00:00:00'));
    $d = DateTime::createFromFormat('Y-m-d H:i:s', $firstNextMonth);
    $firstNextMonthTs = $d->getTimestamp();

但是当我 运行 登台服务器中的代码时,我得到了 magento 错误

"Fatal Error: 'Uncaught Error: Class 'Magenest\Stripe\Model\DateTime' not found in \/var\/www\/html\/magento2-theme-videx\/htdocs\/app\/code\/Magenest\/Stripe\/Model\/StripePaymentMethod.php:480\nStack trace:\n#0 \/var\/www\/html\/magento2-theme-videx\/htdocs\/app\/code\/Magenest\/Stripe\/Model\/StripePaymentMethod.php(829): Magenest\Stripe\Model\StripePaymentMethod->authorize(Object(Magento\Sales\Model\Order\Payment\Interceptor), '4.8')\n#1 \/var\/www\/html\/magento2-theme-videx\/htdocs\/vendor\/magento\/module-sales\/Model\/Order\/Payment\/Operations\/CaptureOperation.php(82): Magenest\Stripe\Model\StripePaymentMethod->capture(Object(Magento\Sales\Model\Order\Payment\Interceptor), '4.8')\n#2 \/var\/www\/html\/magento2-theme-videx\/htdocs\/vendor\/magento\/module-sales\/Model\/Order\/Payment\/Processor.php(85): Magento\Sales\Model\Order\Payment\Operations\CaptureOperation->capture(Object(Magento\Sales\Model\Order\Payment\Interceptor), Object(Magento\Sales\Model\Order\Invoice))\n#3 \/var\/www\/html\/magento2-theme-videx\/htdocs\/vendor\/magento\/module-sales\/Model\/Order\/Payment.php(' in '\/var\/www\/html\/magento2-theme-videx\/htdocs\/app\/code\/Magenest\/Stripe\/Model\/StripePaymentMethod.php' on line 480"

看起来像 magento 或 php 它试图找到 DateTime class 而不是 运行 命令

php 版本是 PHP 7.0.27 (cli)(内置:2018 年 1 月 25 日 22:40:53)(NTS)

有什么想法吗?

在 class 声明之前添加 "use Magento\Framework\Stdlib\DateTime;" 行而不是使用代码 DateTime class 如下:

$firstNextMonth = date("Y-m-d H:i:s", strtotime(date('m', strtotime('+1 month')).'/01/'.date('Y').' 00:00:00'));
$d = \DateTime::createFromFormat('Y-m-d H:i:s', $firstNextMonth);
$firstNextMonthTs = $d->getTimestamp();