本文整理汇总了PHP中Zend_Date::setTimeZone方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Date::setTimeZone方法的具体用法?PHP Zend_Date::setTimeZone怎么用?PHP Zend_Date::setTimeZone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Date
的用法示例。
在下文中一共展示了Zend_Date::setTimeZone方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _prepareCollection
$this->setId('lifetimesalesReportGrid');
$this->setDefaultSort('orders_sum_amount');
$this->setDefaultDir('desc');
}
/**
* @return $this
* @throws Mage_Core_Exception
* @throws Zend_Date_Exception
*/
protected function _prepareCollection()
{
// Get the session
$session = Mage::getSingleton('core/session');
// Dates for one week
$store = Mage_Core_Model_App::ADMIN_STORE_ID;
$timezone = Mage::app()->getStore($store)->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
date_default_timezone_set($timezone);
// Automatic -30 days if no dates provided
if ($session->getLifetimesalesFrom()) {
$sDate = $session->getLifetimesalesFrom();
} else {
$sDate = date('Y-m-d 00:00:00', Mage::getModel('core/date')->timestamp(strtotime('-30 days')));
}
if ($session->getLifetimesalesTo()) {
$eDate = $session->getLifetimesalesTo();
} else {
$eDate = date('Y-m-d 23:59:59', Mage::getModel('core/date')->timestamp(time()));
}
###############################################################################
$start = new Zend_Date($sDate);
$start->setTimeZone("UTC");
$end = new Zend_Date($eDate);
$end->setTimeZone("UTC");
示例2: _setToday
/**
* @throws Zend_Date_Exception
*/
protected function _setToday()
{
// Date handling
$store = Mage_Core_Model_App::ADMIN_STORE_ID;
$timezone = Mage::app()->getStore($store)->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
date_default_timezone_set($timezone);
// Current date
$currentdate = date("Ymd");
$day = (int) substr($currentdate, -2);
$month = (int) substr($currentdate, 4, 2);
$year = (int) substr($currentdate, 0, 4);
$date = array('year' => $year, 'month' => $month, 'day' => $day, 'hour' => 23, 'minute' => 59, 'second' => 59);
$today = new Zend_Date($date);
$today->setTimeZone("UTC");
date_default_timezone_set($timezone);
$this->_today = $today->toString("Y-MM-dd HH:mm:ss");
}
示例3: testZF7154
/**
* @ZF-7154
*/
public function testZF7154()
{
$locale = new Zend_Locale('de_AT');
$date = new Zend_Date(1577833200, $locale);
$date2 = new Zend_Date(2006, Zend_Date::YEAR);
$date->setTimeZone(date_default_timezone_get());
$date->setYear(2000);
$date->setMonth('Apr.');
$this->assertSame('2000-04-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
$date->setYear(2004);
$date->setMonth('Februar');
$this->assertSame('2004-02-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
}
示例4: testDay
/**
* test setting dates to specify weekdays
*/
public function testDay()
{
// all tests and calculations below are in GMT (that is intention for this test)
$date = new Zend_Date(0, 'de_AT');
$date->setTimeZone('UTC');
$dw = $date->getDay();
$this->assertSame($dw->toString(), '01.01.1970 00:00:00');
for ($day = 1; $day < 31; $day++) {
$date->setDay($day);
$dw = $date->getDay();
$weekday = str_pad($day, 2, '0', STR_PAD_LEFT);
$this->assertSame($dw->toString(), "{$weekday}.01.1970 00:00:00");
}
}
示例5: dateTimeFormatLocal
/**
* Gets the localized date according to a specific mask
* @param object $datetime A PHP DateTime Object
* @param string $mask
* @return string
*/
public function dateTimeFormatLocal(&$datetime,$mask) {
$locale = new Zend_Locale(Localization::activeLocale());
$date = new Zend_Date($datetime->format(DATE_ATOM),DATE_ATOM, $locale);
$date->setTimeZone($datetime->format("e"));
return $date->toString($mask);
}
示例6: toZendDate
/**
* Convert a date to a Zend_Date instance.
* @param string|DateTime|Zend_Date|int $value It can be:<ul>
* <li>the special value 'now' (default) to return the current date/time</li>
* <li>a DateTime instance</li>
* <li>a Zend_Date instance</li>
* <li>a string parsable by strtotime (the current system timezone is used)</li>
* <li>a timestamp</li>
* </ul>
* @param string $timezone The timezone to set. Special values are:<ul>
* <li>'system' (default) for the current system timezone</li>
* <li>'user' for the user's timezone</li>
* <li>'app' for the app's timezone</li>
* <li>Other values: one of the PHP supported time zones (see http://us1.php.net/manual/en/timezones.php )</li>
* </ul>
* @return Zend_Date|null Returns the Zend_Date instance (or null if $value couldn't be parsed)
*/
public function toZendDate($value = 'now', $timezone = 'system')
{
$zendDate = null;
if (is_int($value)) {
$zendDate = new Zend_Date($value, Zend_Date::TIMESTAMP);
} elseif ($value instanceof DateTime) {
$zendDate = new Zend_Date($value->format(DATE_ATOM), DATE_ATOM);
$zendDate->setTimeZone($value->format('e'));
} elseif (is_a($value, 'Zend_Date')) {
$zendDate = clone $value;
} elseif (is_string($value) && strlen($value)) {
if ($value === 'now') {
$zendDate = new Zend_Date();
} elseif (is_numeric($value)) {
$zendDate = new Zend_Date($value, Zend_Date::TIMESTAMP);
} else {
$timestamp = @strtotime($value);
if ($timestamp !== false) {
$zendDate = new Zend_Date($timestamp, Zend_Date::TIMESTAMP);
}
}
}
if (is_null($zendDate)) {
return null;
}
$zendDate->setLocale(Localization::activeLocale());
$zendDate->setTimezone($this->getTimezone($timezone));
return $zendDate;
}