# UTC time question

**URL:** <https://discourse.cakephp.org/t/utc-time-question/1228>\
**Category:** Uncategorized\
**Created:** [September 23, 2016, 10:47pm UTC](https://discourse.cakephp.org/t/utc-time-question/1228 "2016-09-23T22:47:28Z")\
**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:** [September 23, 2016, 10:47pm UTC](https://discourse.cakephp.org/t/utc-time-question/1228/1 "2016-09-23T22:47:28Z")

</div>

In ver 3.3.3 I set in bootstrap date\_default\_timezone\_set(‘America/Chicago’);

But in config/app there is this line

```auto
'timezone' => 'UTC',

```

Exactly what is this line for, and do I leave it or change it to local timezone as well. Times are currently storing correctly.  
And a side note I do not use and do not believe in timestamps. I use a date field or if needed a datetime field in the mysql database.

---

<div class="post-metadata">

**Author:** ![rogerpro](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/rogerpro/32/466_2.png) [@rogerpro](https://discourse.cakephp.org/u/rogerpro)\
**Post date:** [February 24, 2017, 5:55pm UTC](https://discourse.cakephp.org/t/utc-time-question/1228/2 "2017-02-24T17:55:24Z")

</div>

The `'timezone'` item in `config/app.php` is included in the `'Datasources'` section, so that means that it’s related to the database time zone configured in the database server.

I set UTC as a time zone for _everything_: the system, the database server, etc. every time that I can. If my customer requires another time zone, then I configure it on the app.

Regarding `date_default_timezone_set('America/Chicago');` there’s a recommendation in the comments of `bootstrap.php`:

```
/*
 * Set server timezone to UTC. You can change it to another timezone of your
 * choice but using UTC makes time calculations / conversions easier.
 */

```

In the 2.x book, there’s some indication that seems to have disappeared in the 3.x book: [https://book.cakephp.org/2.0/en/installation.html#fire-it-up](https://book.cakephp.org/2.0/en/installation.html#fire-it-up) recommending to uncomment the line in case of issues.

In my case, I almost always prefer timestamps rather than datetime fields, because timestamps include the timezone implicitly. So, since the moment that the app will be accessed from users from different time zones and you want them to see dates and times in their local timezone, this field type makes it pretty easy to do it than if the data were saved in datetime fields.

As a plus, in the case of a migration of the database to a system with another timezone, I would feel more confident using timestamps. Not to say possible issues when calculating differences between two moments with a sumer time change in between and needing a precision of 1 hour or less.

For all this reasons, I choose UTC & timestamp fields where posible. And I avoid headaches 😉
