千家信息网

怎么配置Magento2 system.xml dateTime时间

发表于:2024-10-05 作者:千家信息网编辑
千家信息网最后更新 2024年10月05日,这篇文章主要讲解了"怎么配置Magento2 system.xml dateTime时间",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习"怎么配置Mage
千家信息网最后更新 2024年10月05日怎么配置Magento2 system.xml dateTime时间

这篇文章主要讲解了"怎么配置Magento2 system.xml dateTime时间",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习"怎么配置Magento2 system.xml dateTime时间"吧!

配置:

效果:

DateTime文件内容:

namespace Olight\Presale\Block\Adminhtml\System\Config;
class DateTime extends \Magento\Config\Block\System\Config\Form\Field
{

protected $timezone;

public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone,
array $data = []
) {
$this->timezone = $timezone;
parent::__construct($context, $data);
}

public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$element->setDateFormat($this->timezone->getDateFormat());
$element->setTimeFormat($this->timezone->getTimeFormat());
$element->setShowsTime(true);
return parent::render($element);
}
}
?>

感谢各位的阅读,以上就是"怎么配置Magento2 system.xml dateTime时间"的内容了,经过本文的学习后,相信大家对怎么配置Magento2 system.xml dateTime时间这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是,小编将为大家推送更多相关知识点的文章,欢迎关注!

0