gloomy.penguin
gloomy.penguin

Reputation: 5911

How do I use the IANA Timezone database?

http://www.iana.org/time-zones

I want to query this. I really, really do... I'm using PHP and I'm starting to try and make relational things out of the Timezone data with arrays... I'd really like to just query it but I have no idea how to open it. (lol?)

Or the database listed here: http://www.php.net/manual/en/timezones.php (PECL)

This is not for production use. It is for my own sanity. I'm gonna keep going with my array thing... but...

I just really want to know if each city is an individual timezone with individual rules. I do not care about the past - only current. At first I assumed that no, of course not, some of those share timezones and they were just nice and listed more than one city per zone. But! DST rules might be different. Who knows.

How do I open this thing?

Upvotes: 2

Views: 2879

Answers (1)

isidor3
isidor3

Reputation: 36

PHP has the timezone database built in, just use the DateTime and DateTimeZone classes.

Example:

$utc_date = DateTime::createFromFormat(
                'Y-m-d G:i', 
                '2011-04-27 02:45', 
                new DateTimeZone('UTC')
);

$nyc_date = $utc_date;
$nyc_date->setTimeZone(new DateTimeZone('America/New_York'));

echo $nyc_date->format('Y-m-d g:i A'); // output: 2011-04-26 10:45 PM

Source

Upvotes: 2

Related Questions