# Cake 4 Date time format in the data array (SOLVED)

**URL:** <https://discourse.cakephp.org/t/cake-4-date-time-format-in-the-data-array-solved/7744>\
**Category:** Need Help\
**Created:** [April 28, 2020, 11:47am UTC](https://discourse.cakephp.org/t/cake-4-date-time-format-in-the-data-array-solved/7744 "2020-04-28T11:47:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![xv1t](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/xv1t/32/821_2.png) [@xv1t](https://discourse.cakephp.org/u/xv1t)\
**Post date:** [April 28, 2020, 11:47am UTC](https://discourse.cakephp.org/t/cake-4-date-time-format-in-the-data-array-solved/7744/1 "2020-04-28T11:47:49Z")

</div>

Good day!

in MySQL table `workers` field `dateof` with type `datetime`.  
after the query after `toArray()` this field as:

```php
[
   'worker' => [
       'name' => 'Alex is Worker',
       'dateof' => '2020-04-28T09:27:00+05:00'
   ]
]

```

This transform to JSON, but

**2020-04-28T09:27:00+05:00** – What is the format??  
I need a `2020-04-28 14:27:00`

How setup this?

---

<div class="post-metadata">

**Author:** ![xv1t](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/xv1t/32/821_2.png) [@xv1t](https://discourse.cakephp.org/u/xv1t)\
**Post date:** [April 28, 2020, 1:40pm UTC](https://discourse.cakephp.org/t/cake-4-date-time-format-in-the-data-array-solved/7744/2 "2020-04-28T13:40:11Z")

</div>

I’m solved with

```php
use Cake\I18n\FrozenTime;
use Cake\I18n\FrozenDate;
use Cake\I18n\Date;
use Cake\I18n\Time;

Time::setJsonEncodeFormat('yyyy-MM-dd HH:mm:ss'); // For any mutable DateTime
FrozenTime::setJsonEncodeFormat('yyyy-MM-dd HH:mm:ss'); // For any immutable DateTime
Date::setJsonEncodeFormat('yyyy-MM-dd HH:mm:ss'); // For any mutable Date
FrozenDate::setJsonEncodeFormat('yyyy-MM-dd HH:mm:ss'); // For any immutable Date

```

---

<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:** [April 28, 2020, 2:34pm UTC](https://discourse.cakephp.org/t/cake-4-date-time-format-in-the-data-array-solved/7744/3 "2020-04-28T14:34:36Z")

</div>

For the record, the format you were originally getting is a standard form that includes the time zone information, so it eliminates any ambiguity about that. Most APIs will be looking for that format.
