DateTime.php 537 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace common\libs\dataList\column;
  3. class DateTime extends AbstractColumn implements InterfaceColumn {
  4. public $format = 'Y-m-d H:i:s';
  5. public function __construct($config = []) {
  6. parent::__construct($config);
  7. }
  8. public function setFormat($format){
  9. $this->format = $format;
  10. return $this;
  11. }
  12. public function result(){
  13. $value = $this->getValue();
  14. if(!$value){
  15. return $this->defaultText;
  16. }
  17. return date($this->format, $value);
  18. }
  19. }