<p>It's a bit confusing at the moment (should be cleaner in the upcoming Craft 3), but for now, if you use <code>{{ entry.dateCreated|date }}</code>, it should take the timezone into account and display the correct time.</p>

CC BY-SA 3.0
2016-09-15T09:46:26.690Z
Thanks Brad, it is a bit confusing. I was originally using the `{{ entry.dateCreated|datetime }}` filter which shows UTC. If I use `{{ entry.dateCreated|date('d M Y H:i') }}` then I get the local output.
Ant Cooper
CC BY-SA 3.0
2016-09-15T04:43:34.510Z
2016-09-15T09:04:30.907Z
2016-09-15T09:04:30.907Z
Brad Bell
<p>I've written a plugin that stores records in it's own table. I can see that the <code>dateCreated</code> and <code>dateUpdated</code> fields are stored in UTC.</p>

<p>When I want to display them in a CP template, I'm using <code>populateModel</code> and my model contains <code>'dateCreated' =&gt; AttributeType::DateTime</code>.</p>

<p>If I output this with <code>{{ entry.dateCreated|dateTime }}</code> then I'm still getting UTC time and not BST (the Timezone in Settings).</p>

<p>If I use <code>{{ entry.dateCreated|date('d M Y H:i', 'Europe/London') }}</code> then it's correct.</p>

<p>Is there any way to get the date with the correct timezone set automatically?</p>

<plugin-development><localization>
Correct timezone for AttributeType::DateTime in CP
# Correct timezone for AttributeType::DateTime in CP

(Asked by: username_0 on 2016-09-14)

I've written a plugin that stores records in it's own table. I can see that the `dateCreated` and `dateUpdated` fields are stored in UTC.

When I want to display them in a CP template, I'm using `populateModel` and my model contains `'dateCreated' => AttributeType::DateTime`.

If I output this with `{{ entry.dateCreated|dateTime }}` then I'm still getting UTC time and not BST (the Timezone in Settings).

If I use `{{ entry.dateCreated|date('d M Y H:i', 'Europe/London') }}` then it's correct.

Is there any way to get the date with the correct timezone set automatically?

**Tags:** plugin-development, localization

---

## 1 answers

### Answer by username_1 on 2016-09-15. Score: 1

It's a bit confusing at the moment (should be cleaner in the upcoming Craft 3), but for now, if you use `{{ entry.dateCreated|date }}`, it should take the timezone into account and display the correct time.

> **Comments:**
> **username_0**: Thanks Brad, it is a bit confusing. I was originally using the `{{ entry.dateCreated|datetime }}` filter which shows UTC. If I use `{{ entry.dateCreated|date('d M Y H:i') }}` then I get the local output.  

---

