phpactiverecord 检索它并将其存储在扩展的对象中DateTime。
通常你可以->format($yourformat)为任何DateTime对象做,但对于phpactiverecord孩子,你会得到一个默认格式,如果你不提供一个就会被使用。
这个扩展也有一个toString()调用 this 的函数format(),所以你可以得到默认格式(顺便说一下,你可以在同一个类中设置)。
查看DateTime.phpPHPActiveRecord 提供的类以了解更多信息,但会发生以下情况:
class DateTime extends \DateTime{
public static $DEFAULT_FORMAT = 'rfc2822';
//array with formats here
public function format($format=null){
return parent::format(self::get_format($format));
}
public static function get_format($format=null){
//get default format if nothing is provided
}
public function __toString(){
//gets called when you use the object as a string
return $this->format();
}
}