PHP timezone | 6 examples with different identifiers

The timezone in PHP

The PHP date() function can be used to identify the timezone parameters.

The list of characters that can be used for PHP timezone is as given in the examples below with description:

PHP timezone identifier Example

The following example returns timezone identifier by using ‘e’ format character.

PHP timezone

Experience this example online



Output: Returns Timezone identifier (added in PHP 5.1.0)

Timezone for daylight saving time example

Following example returns whether or not the zone is in daylight?

Experience this example online



Output: Whether or not the date is in daylight saving time

Example of returning difference to GMT hours

This example will return the difference with the GMT hours where this PHP script is running.

PHP timezone GMT

Experience this example online



Output: Difference to Greenwich time (GMT) in hours

Experience this example online



Output: Difference to Greenwich time (GMT) with colon between hours and minutes (added in PHP 5.1.3)

PHP timezone abbreviation example

Following example returns timezone abbreviation by using ‘T’ character format of PHP date function.

PHP timezone abbreviation

Experience this example online



Output: Timezone abbreviation

Experience this example online



Output: Timezone offset in seconds. The offset for timezones west of UTC is always negative and for those east of UTC is always positive.

Also read: PHP time | PHP mktime |  getdate() function

Was this article helpful?

Related Articles

Leave A Comment?