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
  • PHP

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:  *
 6:  * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
 7:  *
 8:  * For the full copyright and license information, please view
 9:  * the file license.txt that was distributed with this source code.
10:  */
11: 
12: namespace Nette;
13: 
14: use Nette;
15: 
16: 
17: /**
18:  * DateTime with serialization and timestamp support for PHP 5.2.
19:  *
20:  * @author     David Grudl
21:  */
22: class DateTime extends \DateTime
23: {
24:     /** minute in seconds */
25:     const MINUTE = 60;
26: 
27:     /** hour in seconds */
28:     const HOUR = 3600;
29: 
30:     /** day in seconds */
31:     const DAY = 86400;
32: 
33:     /** week in seconds */
34:     const WEEK = 604800;
35: 
36:     /** average month in seconds */
37:     const MONTH = 2629800;
38: 
39:     /** average year in seconds */
40:     const YEAR = 31557600;
41: 
42: 
43:     /**
44:      * DateTime object factory.
45:      * @param  string|int|\DateTime
46:      * @return DateTime
47:      */
48:     public static function from($time)
49:     {
50:         if ($time instanceof \DateTime) {
51:             return new self($time->format('Y-m-d H:i:s'), $time->getTimezone());
52: 
53:         } elseif (is_numeric($time)) {
54:             if ($time <= self::YEAR) {
55:                 $time += time();
56:             }
57:             return new static(date('Y-m-d H:i:s', $time));
58: 
59:         } else { // textual or NULL
60:             return new static($time);
61:         }
62:     }
63: 
64: 
65:     public function __toString()
66:     {
67:         return $this->format('Y-m-d H:i:s');
68:     }
69: 
70: 
71:     public function modifyClone($modify = '')
72:     {
73:         $dolly = clone $this;
74:         return $modify ? $dolly->modify($modify) : $dolly;
75:     }
76: 
77: 
78:     }
79: 
Nette Framework 2.0.12 API API documentation generated by ApiGen 2.8.0