date_timezone_get


 

date_timezone_get

date_timezone_get alias DateTime::getTimezone function returns time zone relative to given DateTime. It returns DateTimeZone object on success or FALSE on failure.

date_timezone_get alias DateTime::getTimezone function returns time zone relative to given DateTime. It returns DateTimeZone object on success or FALSE on failure.

PHP Date Timzezone Get

The date_timezone_get alias DateTime::getTimezone function returns time zone relative to given DateTime. It returns DateTimeZone object on success or FALSE on failure.

Syntax of date_timezone_get() in php

public DateTimeZone DateTime::getTimezone ( void )
DateTimeZone date_timezone_get ( DateTime $object )

Parameters of date_timezone_get() in php

object - Procedural style only: A DateTime object returned by date_create()

Example of date_timezone_get() in php: Setting and getting DateTimeZone objects

<?php

date_default_timezone_set('India/Kolkata');
$datetime = new DateTime('2009-08-27 16:05:35');
echo $datetime->getTimezone()->getName() . "\n";

$datetime = new DateTime('2009-08-27 16:05:35');
$la_time = new DateTimeZone('America/Los_Angeles');
$datetime->setTimezone($la_time);
echo $datetime->getTimezone()->getName();
?>

The above example will output:

India/Kolkata
America/Los_Angeles

Ads