downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

DateTimeZone> <DateTime::getTimezone
[edit] Last updated: Fri, 14 Jun 2013

view this page in

DateTime::__wakeup

DateTimeImmutable::__wakeup

DateTimeInterface::__wakeup

(PHP 5 >= 5.2.0)

DateTime::__wakeup -- DateTimeImmutable::__wakeup -- DateTimeInterface::__wakeupLe gestionnaire __wakeup

Description

public DateTime::__wakeup ( void )
public DateTimeImmutable::__wakeup ( void )
public DateTimeInterface::__wakeup ( void )

Le gestionnaire __wakeup().

Liste de paramètres

Cette fonction ne contient aucun paramètre.

Valeurs de retour

Initialise un objet DateTime.



add a note add a note User Contributed Notes DateTime::__wakeup - [2 notes]
up
3
prikkeldraad at gmail dot com
4 years ago
If you use a version prior to 5.3 you can make __wakeup and __toString work using the following piece of code.

<?php
class ExtendedDateTime extends DateTime {
    private
$_date_time;
   
    public function
__toString() {
        return
$this->format('c'); // format as ISO 8601
   
}
   
    public function
__sleep() {
       
$this->_date_time = $this->format('c');
        return array(
'_date_time');
    }
   
    public function
__wakeup() {
       
$this->__construct($this->_date_time);
    }
}
?>

Hope this helps someone.
up
-1
TheDO
4 years ago
Be aware, even though this __wake() method exists as of PHP 5.2, DateTime objects don't retain their values when unserialized under PHP 5.2. PHP 5.3 fixes this.

 
show source | credits | sitemap | contact | advertising | mirror sites