Ask a Question

< All Topics
Print

Date incorrect on pdf invoice

Versions: Magento 2.3.4 to 2.4

Please always consider applying patches rather than editing core Magento files. In any case of update or upgrade, you will be losing all changes made to core files. You would not want to do the same thing twice or more times. Here is an example of how to apply Magento patches: github.com 1

Edit file

/vendor/magento/framework/Stdlib/DateTime/Timezone.php (change source code starting from the line approx. 196)

    public function scopeDate($scope = null, $date = null, $includeTime = false)
    {
        $timezone = new \DateTimeZone(
            $this->_scopeConfig->getValue($this->getDefaultTimezonePath(), $this->_scopeType, $scope)
        );
        switch (true) {
            case (empty($date)):
                $date = new \DateTime('now', $timezone);
                break;
            case ($date instanceof \DateTime):
            case ($date instanceof \DateTimeImmutable):
                $date = $date->setTimezone($timezone);
                break;
            default:
                $date = new \DateTime(is_numeric($date) ? '@' . $date : $date);
                $date->setTimezone($timezone);
                break;
        }

        if (!$includeTime) {
            $date->setTime(0, 0, 0);
        }

        return $date;
    }
Reference:
  1. Github[]
Tags:
0 Comment

No Comment.

Table of Contents
Home
Search
WhatsApp