Namespaces

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

Classes

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

Interfaces

  • IFreezable

Exceptions

  • ArgumentOutOfRangeException
  • DeprecatedException
  • DirectoryNotFoundException
  • FatalErrorException
  • FileNotFoundException
  • InvalidArgumentException
  • InvalidStateException
  • IOException
  • MemberAccessException
  • NotImplementedException
  • NotSupportedException
  • OutOfRangeException
  • StaticClassException
  • UnexpectedValueException
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: 
 3: /**
 4:  * This file is part of the Nette Framework (http://nette.org)
 5:  *
 6:  * Copyright (c) 2004, 2011 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 static(date('Y-m-d H:i:s', $time));
60: 
61:         } else { // textual or NULL
62:             return new static($time);
63:         }
64:     }
65: 
66: 
67:     }
68: 
Nette Framework 2.0beta1 API API documentation generated by ApiGen 2.3.0