As quick solution you can create helper in your module
<?php
declare(strict_types=1);
namespace Acme\StackExchange\Helper;
use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Framework\App\Helper\Context;
use Magento\Framework\Locale\ResolverInterface;
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
class Date extends AbstractHelper
{
/**
* @var TimezoneInterface
*/
protected $timezone;
/**
* @var string
*/
protected $locale;
public function __construct(Context $context, TimezoneInterface $timezone, ResolverInterface $localeResolver)
{
parent::__construct($context);
$this->timezone = $timezone;
$this->locale = $localeResolver->getLocale();
}
public function formatDate(string $value, string $format): string
{
$convertedDate = $this->timezone->date(
new \DateTime($value, new \DateTimeZone('UTC')),
$this->locale,
true
);
return $convertedDate->format($format);
}
}
and use this helper in template
// define it in the top
$_dateHelper = $this->helper(\Acme\StackExchange\Helper\Date::class);
// use
echo $_dateHelper->formatDate($_order->getCreatedAt(), 'm/d/Y');