From f92b15f8921f1e0f033fc804165b887355493e1d Mon Sep 17 00:00:00 2001 From: Eelco Bogers Date: Thu, 13 Apr 2023 14:00:58 +0200 Subject: [PATCH] datetime --- README.md | 2 +- src/ORM/Table.php | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b02ca4e..6db735a 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ An Mongodb datasource for CakePHP 3.5 Install [composer](http://getcomposer.org) and run: ```bash -composer require giginc/mongodb 1.0.0 +composer require shockraver/mongodb ``` ## Connecting the Plugin to your application diff --git a/src/ORM/Table.php b/src/ORM/Table.php index a567495..792cc60 100644 --- a/src/ORM/Table.php +++ b/src/ORM/Table.php @@ -7,6 +7,7 @@ use Cake\Chronos\ChronosInterface; use Cake\Datasource\EntityInterface; use Cake\Datasource\Exception\InvalidPrimaryKeyException; +use Cake\I18n\FrozenTime; use Cake\ORM\RulesChecker; use Cake\ORM\Table as CakeTable; use RuntimeException; @@ -213,15 +214,11 @@ protected function _processSave($entity, $options) $data = $entity->toArray(); $isNew = $entity->isNew(); - //convert to mongodate - /** @var ChronosInterface $c */ if (isset($data['created'])) { - $c = $data['created']; - $data['created'] = new \MongoDB\BSON\UTCDateTime(strtotime($c->toDateTimeString())); + $data['created'] = FrozenTime::now()->toIso8601String(); } if (isset($data['modified'])) { - $c = $data['modified']; - $data['modified'] = new \MongoDB\BSON\UTCDateTime(strtotime($c->toDateTimeString())); + $data['modified'] = FrozenTime::now()->toIso8601String(); } if ($isNew) {