Namespaces

  • Nette
    • Application
      • Diagnostics
      • Responses
      • Routers
      • UI
    • Caching
      • Storages
    • ComponentModel
    • Config
      • Adapters
      • Extensions
    • Database
      • Diagnostics
      • Drivers
      • Reflection
      • Table
    • DI
      • Diagnostics
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Latte
      • Macros
    • Loaders
    • Localization
    • Mail
    • Reflection
    • Security
      • Diagnostics
    • Templating
    • Utils
      • PhpGenerator
  • NetteModule
  • none

Classes

  • ArrayHash
  • ArrayList
  • Callback
  • DateTime
  • Environment
  • Framework
  • FreezableObject
  • Image
  • Object
  • ObjectMixin

Interfaces

  • IFreezable

Exceptions

  • ArgumentOutOfRangeException
  • DeprecatedException
  • DirectoryNotFoundException
  • FatalErrorException
  • FileNotFoundException
  • InvalidArgumentException
  • InvalidStateException
  • IOException
  • MemberAccessException
  • NotImplementedException
  • NotSupportedException
  • OutOfRangeException
  • StaticClassException
  • UnexpectedValueException
  • UnknownImageFileException
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
 1: <?php
 2: 
 3: /**
 4:  * This file is part of the Nette Framework (http://nette.org)
 5:  * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
 6:  */
 7: 
 8: namespace Nette;
 9: 
10: use Nette;
11: 
12: 
13: /**
14:  * DateTime with serialization and timestamp support for PHP 5.2.
15:  *
16:  * @author     David Grudl
17:  */
18: class DateTime extends \DateTime
19: {
20:     /** minute in seconds */
21:     const MINUTE = 60;
22: 
23:     /** hour in seconds */
24:     const HOUR = 3600;
25: 
26:     /** day in seconds */
27:     const DAY = 86400;
28: 
29:     /** week in seconds */
30:     const WEEK = 604800;
31: 
32:     /** average month in seconds */
33:     const MONTH = 2629800;
34: 
35:     /** average year in seconds */
36:     const YEAR = 31557600;
37: 
38: 
39:     /**
40:      * DateTime object factory.
41:      * @param  string|int|\DateTime
42:      * @return DateTime
43:      */
44:     public static function from($time)
45:     {
46:         if ($time instanceof \DateTime || $time instanceof \DateTimeInterface) {
47:             return new static($time->format('Y-m-d H:i:s'), $time->getTimezone());
48: 
49:         } elseif (is_numeric($time)) {
50:             if ($time <= self::YEAR) {
51:                 $time += time();
52:             }
53:             $tmp = new static('@' . $time);
54:             $tmp->setTimeZone(new \DateTimeZone(date_default_timezone_get()));
55:             return $tmp;
56: 
57:         } else { // textual or NULL
58:             return new static($time);
59:         }
60:     }
61: 
62: 
63:     public function __toString()
64:     {
65:         return $this->format('Y-m-d H:i:s');
66:     }
67: 
68: 
69:     public function modifyClone($modify = '')
70:     {
71:         $dolly = clone $this;
72:         return $modify ? $dolly->modify($modify) : $dolly;
73:     }
74: 
75: 
76:     public function setTimestamp($timestamp)
77:     {
78:         $zone = PHP_VERSION_ID === 50206 ? new \DateTimeZone($this->getTimezone()->getName()) : $this->getTimezone();
79:         $this->__construct('@' . $timestamp);
80:         $this->setTimeZone($zone);
81:         return $this;
82:     }
83: 
84: 
85:     public function getTimestamp()
86:     {
87:         $ts = $this->format('U');
88:         return is_float($tmp = $ts * 1) ? $ts : $tmp;
89:     }
90: 
91: 
92:     }
93: 
Nette Framework 2.0.16 API API documentation generated by ApiGen 2.8.0