Gabriel Meono
Gabriel Meono

Reputation: 1010

PHP: How to change date() function to Central Time (-6)

I'm using the date function to be displayed for each of my new posts in a CMS. However, I do not know how to change that value according to my timezone, which is UTC−06:00.

This is how I'm doing it:

    $p['time'] = date("F j, Y, h:i a");
    $time = $p['time'];

And this is how it looks:

August 24, 2011, 4:39 pm

Right now if the current time is 10:39 AM, the $time reported should be 4:39PM. I need to get rid of those extra 6 hours somehow.

Upvotes: 2

Views: 4525

Answers (1)

Alex Turpin
Alex Turpin

Reputation: 47776

You could try calling date_default_timezone_set before all your time handling.

date_default_timezone_set("America/Belize");

Timezones reference

Upvotes: 3

Related Questions