<p>Yes, Craft calls <code>date_default_timezone_set('UTC');</code> when initializing, so PHP will output all times in UTC by default.</p>

<p>If you want to output a time using the timezone that Craft has been set to in General Settings, you can do that with a <a href="http://buildwithcraft.com/classreference/etc/dates/DateTime" rel="nofollow">DateTime</a> object.</p>

<pre class="lang-php prettyprint-override"><code>$now = new DateTime();
$time = $now-&gt;format('g:i a');
</code></pre>

CC BY-SA 3.0
2014-10-22T18:12:58.593Z
2014-10-22T18:12:58.593Z
Brandon Kelly
<p>I am using the following in a plugin which I would expect to simply output the time of the server.</p>

<pre><code>// get current time
$time = date("g:i a");
// outputs 9:36am
</code></pre>

<p>In a straight <code>.php</code> file this is correct - however, from within the plugin the time is an hour out - 8:36am. I imagine this might be to do with British Summer Time. However, in Crafts general settings I have set Timezone to UTC+1 (BST) - Europe/London</p>

<datetime>
Should the timezone in general settings effect the output of $time = date("g:ia");?
# Should the timezone in general settings effect the output of $time = date("g:ia");?

(Asked by: username_0 on 2014-10-21)

I am using the following in a plugin which I would expect to simply output the time of the server.
// get current time
$time = date("g:i a");
// outputs 9:36am

In a straight .php file this is correct - however, from within the plugin the time is an hour out - 8:36am. I imagine this might be to do with British Summer Time. However, in Crafts general settings I have set Timezone to UTC+1 (BST) - Europe/London

**Tags:** datetime


---

## 1 answers

### Answer by username_1 on 2014-10-22. Score: 4

Yes, Craft calls date_default_timezone_set('UTC'); when initializing, so PHP will output all times in UTC by default.
If you want to output a time using the timezone that Craft has been set to in General Settings, you can do that with a DateTime object.
$now = new DateTime();
$time = $now->format('g:i a');


---

