public static function DateTimePlus::createFromTimestamp in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Component/Datetime/DateTimePlus.php \Drupal\Component\Datetime\DateTimePlus::createFromTimestamp()
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()
1 call to DateTimePlus::createFromTimestamp()
- DateTimePlusTest::testTimestamp in core/
tests/ Drupal/ Tests/ Component/ Datetime/ DateTimePlusTest.php - Test creating dates from timestamps, and manipulating timezones.
File
- core/
lib/ Drupal/ Component/ Datetime/ DateTimePlus.php, line 163 - Contains \Drupal\Component\Datetime\DateTimePlus.
Class
- DateTimePlus
- Wraps DateTime().
Namespace
Drupal\Component\DatetimeCode
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;
}