<?php


namespace common\libs\dataList\column;


class DateTime extends AbstractColumn implements InterfaceColumn {

    public $format = 'Y-m-d H:i:s';

    public function __construct($config = []) {
        parent::__construct($config);
    }

    public  function setFormat($format){
        $this->format = $format;
        return $this;
    }

    public function result(){
        $value = $this->getValue();
        if(!$value){
            return $this->defaultText;
        }
        return date($this->format, $value);
    }
}