Packages

  • dibi
    • drivers
    • nette
    • reflection
  • None
  • PHP

Classes

  • dibi
  • DibiConnection
  • DibiDataSource
  • DibiDateTime
  • DibiEvent
  • DibiFileLogger
  • DibiFirePhpLogger
  • DibiFluent
  • DibiObject
  • DibiResult
  • DibiResultIterator
  • DibiRow
  • DibiTranslator

Interfaces

  • IDataSource
  • IDibiDriver
  • IDibiReflector
  • IDibiResultDriver

Exceptions

  • DibiDriverException
  • DibiException
  • DibiNotImplementedException
  • DibiNotSupportedException
  • DibiPcreException
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: 
 3: /**
 4:  * This file is part of the "dibi" - smart database abstraction layer.
 5:  *
 6:  * Copyright (c) 2005 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: 
13: 
14: /**
15:  * DateTime with serialization and timestamp support for PHP 5.2.
16:  *
17:  * @author     David Grudl
18:  * @package    dibi
19:  */
20: class DibiDateTime extends DateTime
21: {
22: 
23:     public function __construct($time = 'now', DateTimeZone $timezone = NULL)
24:     {
25:         if (is_numeric($time)) {
26:             $time = date('Y-m-d H:i:s', $time);
27:         }
28:         if ($timezone === NULL) {
29:             parent::__construct($time);
30:         } else {
31:             parent::__construct($time, $timezone);
32:         }
33:     }
34: 
35: 
36: 
37:     public function modifyClone($modify = '')
38:     {
39:         $dolly = clone($this);
40:         return $modify ? $dolly->modify($modify) : $dolly;
41:     }
42: 
43: 
44: 
45:     public function modify($modify)
46:     {
47:         parent::modify($modify);
48:         return $this;
49:     }
50: 
51: 
52: 
53:     public function __sleep()
54:     {
55:         $this->fix = array($this->format('Y-m-d H:i:s'), $this->getTimezone()->getName());
56:         return array('fix');
57:     }
58: 
59: 
60: 
61:     public function __wakeup()
62:     {
63:         $this->__construct($this->fix[0], new DateTimeZone($this->fix[1]));
64:         unset($this->fix);
65:     }
66: 
67: 
68: 
69:     public function getTimestamp()
70:     {
71:         return (int) $this->format('U');
72:     }
73: 
74: 
75: 
76:     public function setTimestamp($timestamp)
77:     {
78:         return $this->__construct(date('Y-m-d H:i:s', $timestamp), new DateTimeZone($this->getTimezone()->getName())); // getTimeZone() crashes in PHP 5.2.6
79:     }
80: 
81: 
82: 
83:     public function __toString()
84:     {
85:         return $this->format('Y-m-d H:i:s');
86:     }
87: 
88: }
89: 
dibi API documentation API documentation generated by ApiGen 2.3.0