65.9K
CodeProject is changing. Read more.
Home

Timezones in PHP

starIconstarIconstarIcon
emptyStarIcon
starIcon
emptyStarIcon

3.84/5 (8 votes)

Aug 5, 2008

CPOL
viewsIcon

37314

downloadIcon

591

List of all timezones in PHP.

TimeZoneList.jpg

Introduction

In PHP 5, there are some methods to set or get the default timezone. For example, using this code, I set the default timezone used by all date/time functions:

<?php
    date_default_timezone_set("Asia/Tehran"); //I set timezone for Tehran
?>

In another example, I set the default timezone for Tokyo:

<?php
    date_default_timezone_set("Asia/Tokyo");
?>

There are many lists of timezones in the PHP manual (for more info about date_default_timezone_set, see here). I just got them into the menu list in HTML.