Home Tutorial Php Phpdate date_timezone_get

 
 

Share on Google+Share on Google+
date_timezone_get
Posted on: August 27, 2009 at 12:00 AM
Advertisement
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

Advertisement

Related Tags for date_timezone_get:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: August 27, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com