# \[Solved\] Return what is actually stored

**URL:** <https://discourse.cakephp.org/t/solved-return-what-is-actually-stored/6009>\
**Category:** Uncategorized\
**Created:** [April 28, 2019, 10:27pm UTC](https://discourse.cakephp.org/t/solved-return-what-is-actually-stored/6009 "2019-04-28T22:27:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jimgwhit](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/jimgwhit/32/378_2.png) [@jimgwhit](https://discourse.cakephp.org/u/jimgwhit)\
**Post date:** [April 28, 2019, 10:27pm UTC](https://discourse.cakephp.org/t/solved-return-what-is-actually-stored/6009/1 "2019-04-28T22:27:06Z")

</div>

To Cakephp team:

First see: [Cake PHP 3.7 Date](https://discourse.cakephp.org/t/cake-php-3-7-date/6001/6)

I just tested the same query in laravel 5.8 and cakephp 4:

### cakephp 4

```auto
    public function itest()
    {
        $this->autoRender = false;
        $petid = 9;
        $pet = TableRegistry::getTableLocator()->get('Pets');
            $data = $pet
                    ->find()
                    ->where(['petid' => $petid])
                    ->first();
            $testdate = $data->odate;
            $json = json_encode($testdate);
            echo $json;
            exit();
    }

}

```

### Returns:

```ruby
"1998-09-02T00:00:00+00:00"

```

### Laravel 5.8

```auto
    public function itest()
    {
        $petid = 9;
        $pet = Pet::find($petid);
        $testdate = $pet->odate;
        $json = json_encode($testdate);
        echo $json;
        exit();
    }

```

### returns

```ruby
"1998-09-02"

```

Why do you manipulate the orm and query builder to return what you want instead of a value that is actually stored.

I am not trying to cut anyone down, but I just don’t understand the core team manipulating users stored data.

In this case 1998-09-02 is what’s actually stored.

And I am not new to this stuff, I am currently number 14 on laravels top 50, I have used it since ver 4.2, and have used cakephp for some apps.

Why do you determine what’s returned instead of just letting mysql and pdo do their job.

I know I can do a work-a-round

```auto
public function itest()
    {
        $this->autoRender = false;
        $petid = 9;
        $pet = TableRegistry::getTableLocator()->get('Pets');
            $data = $pet
                    ->find()
                    ->where(['petid' => $petid])
                    ->first();
            $testdate = new \DateTime($data->odate);
            $newdate = $testdate->format('Y-m-d');
            $json = json_encode($newdate);
            echo $json;
            exit();
    }

```

### Returns correctly:

```ruby
"1998-09-02"

```

But shouldn’t have to do work a rounds.

---

<div class="post-metadata">

**Author:** ![jimgwhit](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/jimgwhit/32/378_2.png) [@jimgwhit](https://discourse.cakephp.org/u/jimgwhit)\
**Post date:** [April 29, 2019, 12:29am UTC](https://discourse.cakephp.org/t/solved-return-what-is-actually-stored/6009/2 "2019-04-29T00:29:12Z")

</div>

Fixed with in config/bootstrap.php

### change

```ruby
TypeFactory::build('time')
    ->useImmutable();
TypeFactory::build('date')
    ->useImmutable();
TypeFactory::build('datetime')
    ->useImmutable();
TypeFactory::build('timestamp')
    ->useImmutable();

```

### To:

```ruby
TypeFactory::build('time')
        ->useImmutable();
TypeFactory::build('date')
        ->useImmutable()
        ->useLocaleParser()
        ->setLocaleFormat("yyyy-MM-dd");
TypeFactory::build('datetime')
        ->useImmutable();
TypeFactory::build('timestamp')
        ->useImmutable();

```

In other versions it might be:

```ruby
Type::build('date')

```

instead of

```ruby
TypeFactory::build('date')

```

If Type , use it, if TypeFactory use that.

At least put big red warnings in the manual when data isn’t returning what is actually stored.
