for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Sco\Admin\View\Columns;
use Carbon\Carbon;
class DateTime extends Column
{
/**
* Datetime format.
* @var string
*/
protected $format;
* Datetime timezone.
protected $timezone;
* @return string
public function getFormat()
if (is_null($this->format)) {
$this->format = config('admin.datetimeFormat');
}
return $this->format;
public function getTimezone()
if (is_null($this->timezone)) {
$this->timezone = config('app.timezone');
return $this->timezone;
* @param string $format
*
* @return $this
public function setFormat($format)
$this->format = $format;
return $this;
* @param string $timezone
public function setTimezone($timezone)
$this->timezone = $timezone;
public function getModelValue()
$value = parent::getModelValue();
return $this->getFormatValue($value);
public function getFormatValue($date)
if (!is_null($date)) {
if (!$date instanceof Carbon) {
$date = Carbon::parse($date);
$date->timezone($this->getTimezone());
if ($this->getFormat() == 'humans') {
$date = $date->diffForHumans();
} else {
$date = $date->format($this->getFormat());
return $date;