# CakePhp 4.0.1 Postgres timestamp without timezone

**URL:** <https://discourse.cakephp.org/t/cakephp-4-0-1-postgres-timestamp-without-timezone/7038>\
**Category:** Need Help\
**Created:** [December 29, 2019, 6:40am UTC](https://discourse.cakephp.org/t/cakephp-4-0-1-postgres-timestamp-without-timezone/7038 "2019-12-29T06:40:16Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![cielo2](https://avatars.discourse-cdn.com/v4/letter/c/e9a140/32.png) [@cielo2](https://discourse.cakephp.org/u/cielo2)\
**Post date:** [December 29, 2019, 6:40am UTC](https://discourse.cakephp.org/t/cakephp-4-0-1-postgres-timestamp-without-timezone/7038/1 "2019-12-29T06:40:16Z")

</div>

I use Postgres.  
Users.created is timestamp without timezone  
When i have Users.created in the query, i receive this error:  
DateTimeImmutable::\_\_construct(): Failed to parse time string (19/03/2015 22:37:48) at position 0 (1): Unexpected character

---

<div class="post-metadata">

**Author:** ![spadeX](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@spadeX](https://discourse.cakephp.org/u/spadeX)\
**Post date:** [December 30, 2019, 11:52am UTC](https://discourse.cakephp.org/t/cakephp-4-0-1-postgres-timestamp-without-timezone/7038/2 "2019-12-30T11:52:13Z")

</div>

You can check on following link you got something helpful  
[https://github.com/cakephp/cakephp/issues/13646](https://github.com/cakephp/cakephp/issues/13646)

---

<div class="post-metadata">

**Author:** ![coreytaylor](https://avatars.discourse-cdn.com/v4/letter/c/87869e/32.png) [@coreytaylor](https://discourse.cakephp.org/u/coreytaylor)\
**Post date:** [December 31, 2019, 12:15am UTC](https://discourse.cakephp.org/t/cakephp-4-0-1-postgres-timestamp-without-timezone/7038/3 "2019-12-31T00:15:34Z")

</div>

You need to change the format of the timestamp string to something DateTime supports.

---

<div class="post-metadata">

**Author:** ![cielo2](https://avatars.discourse-cdn.com/v4/letter/c/e9a140/32.png) [@cielo2](https://discourse.cakephp.org/u/cielo2)\
**Post date:** [December 31, 2019, 7:27am UTC](https://discourse.cakephp.org/t/cakephp-4-0-1-postgres-timestamp-without-timezone/7038/4 "2019-12-31T07:27:59Z")

</div>

The format in the Users.created field is the “normal” 2015-03-19 22:37:48

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [December 31, 2019, 4:36pm UTC](https://discourse.cakephp.org/t/cakephp-4-0-1-postgres-timestamp-without-timezone/7038/5 "2019-12-31T16:36:51Z")

</div>

Your error message indicates that it’s got a string like “19/03/2015 22:37:48”, though.

---

<div class="post-metadata">

**Author:** ![cielo2](https://avatars.discourse-cdn.com/v4/letter/c/e9a140/32.png) [@cielo2](https://discourse.cakephp.org/u/cielo2)\
**Post date:** [January 1, 2020, 6:37am UTC](https://discourse.cakephp.org/t/cakephp-4-0-1-postgres-timestamp-without-timezone/7038/6 "2020-01-01T06:37:34Z")

</div>

Yes, but i don’t know, why in the error message i have 19/03/2015 22:37:48  
My App.defaultLocale = ‘en\_US’  
App.defaultTimezone = ‘UTC’  
Datasources.default.‘timezone’ = ‘UTC’  
in /config/app\_local.php all the settings are the default recomended settings

The error looks to be in  
ROOT/vendor/cakephp/chronos/src/Chronos.php:99

---

<div class="post-metadata">

**Author:** ![coreytaylor](https://avatars.discourse-cdn.com/v4/letter/c/87869e/32.png) [@coreytaylor](https://discourse.cakephp.org/u/coreytaylor)\
**Post date:** [January 2, 2020, 9:24am UTC](https://discourse.cakephp.org/t/cakephp-4-0-1-postgres-timestamp-without-timezone/7038/7 "2020-01-02T09:24:56Z")

</div>

I assume your database is doing this. What does running the query return?

You don’t show us anything other than the error.

---

<div class="post-metadata">

**Author:** ![cielo2](https://avatars.discourse-cdn.com/v4/letter/c/e9a140/32.png) [@cielo2](https://discourse.cakephp.org/u/cielo2)\
**Post date:** [January 2, 2020, 10:33am UTC](https://discourse.cakephp.org/t/cakephp-4-0-1-postgres-timestamp-without-timezone/7038/8 "2020-01-02T10:33:35Z")

</div>

If i don’t have in the query the field Users.created, everithing goes fine.  
If i have in the query the field Users.created, in stops on the error that i show you.

---

<div class="post-metadata">

**Author:** ![spadeX](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@spadeX](https://discourse.cakephp.org/u/spadeX)\
**Post date:** [January 3, 2020, 12:30pm UTC](https://discourse.cakephp.org/t/cakephp-4-0-1-postgres-timestamp-without-timezone/7038/9 "2020-01-03T12:30:06Z")

</div>

Well, I have also used that PostgreSQL -  
Created - use timestamp with time zone it’s works for me.

---

<div class="post-metadata">

**Author:** ![cielo2](https://avatars.discourse-cdn.com/v4/letter/c/e9a140/32.png) [@cielo2](https://discourse.cakephp.org/u/cielo2)\
**Post date:** [February 4, 2020, 12:13am UTC](https://discourse.cakephp.org/t/cakephp-4-0-1-postgres-timestamp-without-timezone/7038/10 "2020-02-04T00:13:52Z")

</div>

can you please help me, i write more details on

> [@CakePHP 4.0.2 the error persist for Postgres timestamp without time zone](https://discourse.cakephp.org/t/cakephp-4-0-2-the-error-persist-for-postgres-timestamp-without-time-zone/7163):
>
> Because i am interested to migrate to CakePHP 4 now i give more details: pls don’t suggest to change the database or field type Environment: Your version of PHP is 7.2.0 or higher (detected 7.2.26-1+ubuntu18.04.1+deb.sury.org+1). Your version of PHP has the mbstring extension loaded. Your version of PHP has the openssl extension loaded. Your version of PHP has the intl extension loaded. models and controllers was created by bake configs are from: [https://github.com/cakephp/app/tree/maste…](https://github.com/cakephp/app/tree/master/config)

---

<div class="post-metadata">

**Author:** ![cielo2](https://avatars.discourse-cdn.com/v4/letter/c/e9a140/32.png) [@cielo2](https://discourse.cakephp.org/u/cielo2)\
**Post date:** [February 4, 2020, 12:15am UTC](https://discourse.cakephp.org/t/cakephp-4-0-1-postgres-timestamp-without-timezone/7038/11 "2020-02-04T00:15:26Z")

</div>

can you please help me, i write more details here

> [@CakePHP 4.0.2 the error persist for Postgres timestamp without time zone](https://discourse.cakephp.org/t/cakephp-4-0-2-the-error-persist-for-postgres-timestamp-without-time-zone/7163):
>
> Because i am interested to migrate to CakePHP 4 now i give more details: pls don’t suggest to change the database or field type Environment: Your version of PHP is 7.2.0 or higher (detected 7.2.26-1+ubuntu18.04.1+deb.sury.org+1). Your version of PHP has the mbstring extension loaded. Your version of PHP has the openssl extension loaded. Your version of PHP has the intl extension loaded. models and controllers was created by bake configs are from: [https://github.com/cakephp/app/tree/maste…](https://github.com/cakephp/app/tree/master/config)
