You are here

public static function PersianDateFactory::buildFromTimestamp 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::buildFromTimestamp()

Parameters

integer $timestamp:

\DateTimeZone $timezone:

Return value

PersianDate

1 call to PersianDateFactory::buildFromTimestamp()
PersianDateFormatter::format in src/Service/Formatter/PersianDateFormatter.php
Formats a date, using a date type or a custom date format string.

File

src/Converter/PersianDateFactory.php, line 67

Class

PersianDateFactory
This class is responsible to build Persian DateTime instances.

Namespace

Drupal\persian_date\Converter

Code

public static function buildFromTimestamp($timestamp, \DateTimeZone $timezone = null) {
  $dateTime = new PersianDate();
  $dateTime
    ->setTimestamp($timestamp);
  if ($timezone) {
    $dateTime
      ->setTimezone($timezone);
  }
  return $dateTime;
}