Share on Google+Share on Google+

date_timezone_get

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

Advertisements

Advertisement

Posted on: August 27, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial 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.