DateTimePlus::createFromTimestamp

public static DateTimePlus::createFromTimestamp($timestamp, $timezone = NULL, $settings = array())

Creates a date object from timestamp input.

The timezone of a timestamp is always UTC. The timezone for a timestamp indicates the timezone used by the format() method.

Parameters

int $timestamp: A UNIX timestamp.

mixed $timezone: @see __construct()

array $settings: @see __construct()

Return value

static A new DateTimePlus object.

Throws

\Exception If the timestamp is not numeric.

File

core/lib/Drupal/Component/Datetime/DateTimePlus.php, line 170

Class

DateTimePlus
Wraps DateTime().

Namespace

Drupal\Component\Datetime

Code

public static function createFromTimestamp($timestamp, $timezone = NULL, $settings = array()) {
  if (!is_numeric($timestamp)) {
    throw new \Exception('The timestamp must be numeric.');
  }
  $datetime = new static('', $timezone, $settings);
  $datetime->setTimestamp($timestamp);
  return $datetime;
}
doc_Drupal
2016-10-29 09:01:02
Comments
Leave a Comment

Please login to continue.