本文整理汇总了PHP中JDate::getOffsetFromGmt方法的典型用法代码示例。如果您正苦于以下问题:PHP JDate::getOffsetFromGmt方法的具体用法?PHP JDate::getOffsetFromGmt怎么用?PHP JDate::getOffsetFromGmt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JDate
的用法示例。
在下文中一共展示了JDate::getOffsetFromGmt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetOffsetFromGmt
/**
* Testing getOffsetFromGMT
*
* @param mixed $tz Which time zone? (can be string or numeric
* @param string $setTime What time should be set?
* @param boolean $hours Return offset in hours (true) or seconds?
* @param string $expected What should the resulting time string look like?
*
* @return void
*
* @dataProvider casesGetOffsetFromGmt
* @since 11.3
* @covers JDate::getOffsetFromGMT
*/
public function testGetOffsetFromGmt($tz, $setTime, $hours, $expected)
{
if (is_null($tz)) {
$testJDate = new JDate($setTime);
} else {
$testJDate = new JDate($setTime, $tz);
}
if (is_null($hours)) {
$offset = $testJDate->getOffsetFromGmt();
} else {
$offset = $testJDate->getOffsetFromGmt($hours);
}
$this->assertThat($offset, $this->equalTo($expected));
}
示例2: testGetOffsetFromGmt
/**
* Testing getOffsetFromGMT
*
* @param mixed $tz Which time zone? (can be string or numeric
* @param string $setTime What time should be set?
* @param boolean $hours Return offset in hours (true) or seconds?
* @param string $expected What should the resulting time string look like?
*
* @return void
*
* @dataProvider casesGetOffsetFromGmt
* @since 11.3
* @covers JDate::getOffsetFromGMT
*/
public function testGetOffsetFromGmt($tz, $setTime, $hours, $expected)
{
$testJDate = new JDate($setTime, $tz);
$offset = $testJDate->getOffsetFromGmt($hours);
$this->assertEquals($expected, $offset);
}