You are here

static function PersianDateFactory::buildFromOriginalDateTime in Persian Date for Drupal 8 8

Same name and namespace in other branches
  1. 8.4 src/Converter/PersianDateFactory.php \Drupal\persian_date\Converter\PersianDateFactory::buildFromOriginalDateTime()

Bulid PersianDateTime instance from original PHP DateTime object.

Parameters

\DateTime $dateTime:

Return value

PersianDate

1 call to PersianDateFactory::buildFromOriginalDateTime()
PersianDrupalDateTime::format in src/Plugin/Datetime/PersianDrupalDateTime.php
Overrides format().

File

src/Converter/PersianDateFactory.php, line 54

Class

PersianDateFactory
This class is responsible to build Persian DateTime instances.

Namespace

Drupal\persian_date\Converter

Code

static function buildFromOriginalDateTime(\DateTime $dateTime) {
  $object = new PersianDate();
  $object
    ->setTimezone($dateTime
    ->getTimezone());
  $object
    ->setTimestamp($dateTime
    ->getTimestamp());
  return $object;
}