- Fixed Datetime output
This commit is contained in:
parent
2f43fb4559
commit
8a16ab8062
|
@ -5,11 +5,13 @@ namespace Ulmus\Entity\Field;
|
||||||
use Ulmus\Entity\EntityObjectInterface;
|
use Ulmus\Entity\EntityObjectInterface;
|
||||||
|
|
||||||
class Datetime extends \DateTime implements EntityObjectInterface {
|
class Datetime extends \DateTime implements EntityObjectInterface {
|
||||||
|
|
||||||
public function load(...$arguments)
|
public string $format = "Y-m-d H:i:s";
|
||||||
|
|
||||||
|
public function load(...$arguments)
|
||||||
{
|
{
|
||||||
$value = $arguments[0];
|
$value = $arguments[0];
|
||||||
|
|
||||||
# From Timestamp
|
# From Timestamp
|
||||||
if ( is_numeric($value) ) {
|
if ( is_numeric($value) ) {
|
||||||
return new static("@$value");
|
return new static("@$value");
|
||||||
|
@ -17,15 +19,15 @@ class Datetime extends \DateTime implements EntityObjectInterface {
|
||||||
|
|
||||||
return new static($value);
|
return new static($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function save()
|
public function save()
|
||||||
{
|
{
|
||||||
return $this->getTimestamp();
|
return $this->__toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __toString()
|
public function __toString()
|
||||||
{
|
{
|
||||||
return $this->format("Y-m-d H:i:s");
|
return $this->format($this->format);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue