mirror of
https://github.com/dg/dibi.git
synced 2025-10-22 10:16:02 +02:00
55 lines
975 B
PHP
55 lines
975 B
PHP
<?php
|
|
|
|
/**
|
|
* Nette Framework
|
|
*
|
|
* @copyright Copyright (c) 2004, 2010 David Grudl
|
|
* @license http://nette.org/license Nette license
|
|
* @link http://nette.org
|
|
* @category Nette
|
|
* @package Nette
|
|
*/
|
|
|
|
// no namespace
|
|
|
|
|
|
|
|
/**
|
|
* DateTime with serialization and timestamp support for PHP 5.2.
|
|
*
|
|
* @copyright Copyright (c) 2004, 2010 David Grudl
|
|
* @package Nette
|
|
*/
|
|
class DateTime53 extends DateTime
|
|
{
|
|
|
|
public function __sleep()
|
|
{
|
|
$this->fix = array($this->format('Y-m-d H:i:s'), $this->getTimezone()->getName());
|
|
return array('fix');
|
|
}
|
|
|
|
|
|
|
|
public function __wakeup()
|
|
{
|
|
$this->__construct($this->fix[0], new DateTimeZone($this->fix[1]));
|
|
unset($this->fix);
|
|
}
|
|
|
|
|
|
|
|
public function getTimestamp()
|
|
{
|
|
return (int) $this->format('U');
|
|
}
|
|
|
|
|
|
|
|
public function setTimestamp($timestamp)
|
|
{
|
|
return $this->__construct(date('Y-m-d H:i:s', $timestamp), new DateTimeZone($this->getTimezone()->getName())); // getTimeZone() crashes in PHP 5.2.6
|
|
}
|
|
|
|
}
|