本文整理汇总了PHP中DateTimeUtil::convertFromUtcUnixStampByTimeZone方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTimeUtil::convertFromUtcUnixStampByTimeZone方法的具体用法?PHP DateTimeUtil::convertFromUtcUnixStampByTimeZone怎么用?PHP DateTimeUtil::convertFromUtcUnixStampByTimeZone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTimeUtil
的用法示例。
在下文中一共展示了DateTimeUtil::convertFromUtcUnixStampByTimeZone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: convertFromUtcTimeStampForCurrentUser
/**
* Given a utc time stamp, convert the time stamp to a timezone adjusted time stamp.
* The time zone is based on the current user's time zone.
*/
public function convertFromUtcTimeStampForCurrentUser($utcTimeStamp)
{
assert('is_int($utcTimeStamp)');
$timeZone = $this->getForCurrentUser();
return DateTimeUtil::convertFromUtcUnixStampByTimeZone($utcTimeStamp, $timeZone);
}
示例2: testConvertFromUtcUnixStampByTimeZone
public function testConvertFromUtcUnixStampByTimeZone()
{
$timeZoneObject = new DateTimeZone('America/Chicago');
$offset = $timeZoneObject->getOffset(new DateTime());
$this->assertTrue($offset == -18000 || $offset == -21600);
$utcTimeStamp = time();
$adjustedTimeStamp = DateTimeUtil::convertFromUtcUnixStampByTimeZone($utcTimeStamp, 'America/Chicago');
$this->assertEquals($utcTimeStamp + $offset, $adjustedTimeStamp);
//other locales
$timeZoneObject = new DateTimeZone('America/New_York');
$offset = $timeZoneObject->getOffset(new DateTime());
$this->assertTrue($offset == -18000 || $offset == -14400);
$adjustedTimeStamp = DateTimeUtil::convertFromUtcUnixStampByTimeZone($utcTimeStamp, 'America/New_York');
$this->assertEquals($utcTimeStamp + $offset, $adjustedTimeStamp);
}