Namespaces

  • Nette
    • Application
    • Caching
    • Collections
    • Config
    • Forms
    • IO
    • Loaders
    • Mail
    • Reflection
    • Security
    • Templates
    • Web
  • None
  • PHP

Classes

  • ArrayTools
  • Callback
  • Component
  • ComponentContainer
  • Configurator
  • DateTime
  • Debug
  • Environment
  • Framework
  • FreezableObject
  • GenericRecursiveIterator
  • Image
  • ImageMagick
  • InstanceFilterIterator
  • Object
  • ObjectMixin
  • Paginator
  • RecursiveComponentIterator
  • ServiceLocator
  • SmartCachingIterator
  • String
  • Tools

Interfaces

  • IComponent
  • IComponentContainer
  • IDebuggable
  • IServiceLocator
  • ITranslator

Exceptions

  • AmbiguousServiceException
  • Overview
  • Namespace
  • Class
  • Tree
  • Other releases
 1: <?php
 2: 
 3: /**
 4:  * This file is part of the Nette Framework (https://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: /**
19:  * DateTime with serialization and timestamp support for PHP 5.2.
20:  *
21:  * @author     David Grudl
22:  */
23: class DateTime extends \DateTime
24: {
25:     /** minute in seconds */
26:     const MINUTE = 60;
27: 
28:     /** hour in seconds */
29:     const HOUR = 3600;
30: 
31:     /** day in seconds */
32:     const DAY = 86400;
33: 
34:     /** week in seconds */
35:     const WEEK = 604800;
36: 
37:     /** average month in seconds */
38:     const MONTH = 2629800;
39: 
40:     /** average year in seconds */
41:     const YEAR = 31557600;
42: 
43: 
44: 
45:     /**
46:      * DateTime object factory.
47:      * @param  string|int|\DateTime
48:      * @return DateTime
49:      */
50:     public static function from($time)
51:     {
52:         if ($time instanceof \DateTime) {
53:             return clone $time;
54: 
55:         } elseif (is_numeric($time)) {
56:             if ($time <= self::YEAR) {
57:                 $time += time();
58:             }
59:             return new self(date('Y-m-d H:i:s', $time));
60: 
61:         } else { // textual or NULL
62:             return new self($time);
63:         }
64:     }
65: 
66: 
67:     }
68: 
Nette Framework 0.9.7 API documentation generated by ApiGen 2.3.0