From 8a16ab8062c316fe93d21e627eeadd0ee6ba66f5 Mon Sep 17 00:00:00 2001 From: Dave Mc Nicoll Date: Mon, 10 Feb 2020 15:19:46 -0500 Subject: [PATCH] - Fixed Datetime output --- src/Entity/Field/Datetime.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Entity/Field/Datetime.php b/src/Entity/Field/Datetime.php index a40fbeb..af12034 100644 --- a/src/Entity/Field/Datetime.php +++ b/src/Entity/Field/Datetime.php @@ -5,11 +5,13 @@ namespace Ulmus\Entity\Field; use Ulmus\Entity\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]; - + # From Timestamp if ( is_numeric($value) ) { return new static("@$value"); @@ -17,15 +19,15 @@ class Datetime extends \DateTime implements EntityObjectInterface { return new static($value); } - - public function save() + + public function save() { - return $this->getTimestamp(); + return $this->__toString(); } - + public function __toString() { - return $this->format("Y-m-d H:i:s"); + return $this->format($this->format); } - -} \ No newline at end of file + +}