PHP 5.4.33 Released

DateTime::__wakeup

(PHP 5 >= 5.2.0)

DateTime::__wakeupThe __wakeup handler

Description

public DateTime DateTime::__wakeup ( void )

هندلر __wakeup.

Parameters

This function has no parameters.

Return Values

آغاز شی DateTime.

add a note add a note

User Contributed Notes 1 note

up
5
prikkeldraad at gmail dot com
5 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.
To Top