4
* This file is part of the Nette Framework (http://nette.org)
6
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
8
* For the full copyright and license information, please view
9
* the file license.txt that was distributed with this source code.
22
class DateTime extends \DateTime
24
/** minute in seconds */
27
/** hour in seconds */
33
/** week in seconds */
36
/** average month in seconds */
37
const MONTH = 2629800;
39
/** average year in seconds */
40
const YEAR = 31557600;
44
* DateTime object factory.
45
* @param string|int|\DateTime
48
public static function from($time)
50
if ($time instanceof \DateTime || $time instanceof \DateTimeInterface) {
51
return new static($time->format('Y-m-d H:i:s'), $time->getTimezone());
53
} elseif (is_numeric($time)) {
54
if ($time <= self::YEAR) {
57
return new static(date('Y-m-d H:i:s', $time));
59
} else { // textual or NULL
60
return new static($time);
65
public function __toString()
67
return $this->format('Y-m-d H:i:s');
71
public function modifyClone($modify = '')
74
return $modify ? $dolly->modify($modify) : $dolly;