/**
	 * Return a set of timezone information relevant to this joyful stuff :D
	 */
	public static function zoneInfo() {
		$zones = array();
		$now = date_create();
		foreach( timezone_identifiers_list() as $tz ) {
			$zone = timezone_open( $tz );

			$name = timezone_name_get( $zone );
			$location = timezone_location_get( $zone );
			$offset = timezone_offset_get( $zone, $now ) / 60; // convert seconds to minutes

			$zones[] = array('name' => $name, 'offset' => $offset, 'location' => $location);
		}
		return $zones;
	}
Пример #2
0
<?php

class MyDateTime extends DateTime
{
    public function __construct()
    {
    }
}
class MyDateTimeZone extends DateTimeZone
{
    public function __construct()
    {
    }
}
$o = new MyDateTime();
var_dump($o->format("d"));
$x = clone $o;
var_dump($x->format("d"));
clone $o;
var_dump(timezone_location_get(clone new MyDateTimezone()));
Пример #3
0
echo "<br/>";
$winter = new DateTime('2010-12-21', new DateTimeZone('America/New_York'));
$summer = new DateTime('2008-06-21', new DateTimeZone('America/New_York'));
echo $winter->getOffset() . "\n";
echo $summer->getOffset() . "\n";
echo "<br/>";
$date = new DateTime();
echo $date->getTimestamp();
echo "<br/>";
$date = new DateTime(null, new DateTimeZone('Europe/London'));
$tz = $date->getTimezone();
echo $tz->getName();
echo "<br/>";
echo "<pre>";
$tz = new DateTimeZone("Europe/Prague");
print_r($tz->getLocation());
print_r(timezone_location_get($tz));
//checkdate用于验证一个验证一个格里高里日期(就是公历)
var_dump(checkdate(12, 31, 2000));
var_dump(checkdate(2, 29, 2001));
echo "<br/>";
echo "<pre>";
print_r(date_parse("2006-12-12 10:00:00.5"));
echo "<br/>";
echo "<pre>";
$today = getdate();
print_r($today);
//返回Uinx时间戳
echo "<br/>";
//hour,minute,second,month,day,year
echo mktime(0, 0, 0, 1, 1, 2000);
Пример #4
0
<?php

$location = timezone_location_get(new DateTimeZone("Europe/Oslo"));
var_dump($location);
Пример #5
0
function test_timezone_location_get()
{
    $tz = timezone_open("Europe/Prague");
    $loc = timezone_location_get($tz);
    return $loc;
}