user6941747
user6941747

Reputation:

PHP DateTimeZone Member Access

I have a DateTimeZone object, let us call this $TimeZone.

DateTimeZone Object
(
    [timezone_type] => 2
    [timezone] => Z
)

I want to get timezone_type and timezone as string values. I have got timezone using the following line-

$timezone=$TimeZone->getName();

But I am not getting $timezone_type.

Upvotes: 0

Views: 28

Answers (1)

Suchit kumar
Suchit kumar

Reputation: 11859

there is a thread related to this issue see this:Here

A hack can be, you can convert the object to array then access the index:

$date = new DateTimeZone('Europe/London');
$x=(array) $date;
echo $x['timezone_type'];//3

Upvotes: 1

Related Questions