本文整理汇总了PHP中Zend_Date::setLocale方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Date::setLocale方法的具体用法?PHP Zend_Date::setLocale怎么用?PHP Zend_Date::setLocale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Date
的用法示例。
在下文中一共展示了Zend_Date::setLocale方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: convertDateToStoreTimestamp
public function convertDateToStoreTimestamp($date, $store = null)
{
try {
if (Mage::getStoreConfigFlag('xtcore/compatibility_fixes/disable_timestamp_timezone_adjustment')) {
$dateObj = new Zend_Date();
$dateObj->set($date, Varien_Date::DATETIME_INTERNAL_FORMAT);
return (int) $dateObj->get(null, Zend_Date::TIMESTAMP);
}
$dateObj = new Zend_Date();
$dateObj->setTimezone(Mage_Core_Model_Locale::DEFAULT_TIMEZONE);
$dateObj->set($date, Varien_Date::DATETIME_INTERNAL_FORMAT);
$dateObj->setLocale(Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE, $store));
$dateObj->setTimezone(Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE, $store));
$gmtOffset = $dateObj->getGmtOffset();
if ($gmtOffset >= 0) {
if (Mage::getStoreConfigFlag('xtcore/compatibility_fixes/zend_date_gmt_offset')) {
// Note: Some Zend_Date versions always return a positive $gmtOffset. Thus, we replace + with - below if affected by this.
return (int) $dateObj->get(null, Zend_Date::TIMESTAMP) - $gmtOffset;
} else {
return (int) $dateObj->get(null, Zend_Date::TIMESTAMP) + $gmtOffset;
}
} else {
return (int) $dateObj->get(null, Zend_Date::TIMESTAMP) - $gmtOffset;
}
} catch (Exception $e) {
return null;
}
}
示例2: Format
public function Format($format = null, $localized = true)
{
if ($this->value) {
$zendDate = new Zend_Date($this->getValue(), 'y-MM-dd');
if ($localized) {
$zendDate->setLocale(i18n::get_locale());
}
return $zendDate->toString($format);
}
}
示例3: format
public function format($format = 'Y-m-d', $language = null)
{
$needsZendDate = !!array_intersect(array('D', 'l', 'S', 'F', 'M', 'e'), str_split($format));
if (!$needsZendDate) {
return date($format, $this->_timestamp);
} else {
$date = new Zend_Date($this->_timestamp, Zend_Date::TIMESTAMP);
$date->setOptions(array('format_type' => 'php'));
$date->setLocale($language);
return $date->toString($format);
}
}
示例4: getTime
/**
* Imprime a data no formato correto
*
* @param date $d Data a ser impressa
* @param string $format Formato da data
* @param string $locale Localização da data
*
*/
public function getTime($d, $format = null, $locale = null)
{
// Define o formato
if (!isset($format)) {
$format = Zend_Date::ISO_8601;
} elseif ($format == 'twitter') {
$format = 'EEE MMM dd HH:mm:ss ZZZ yyyy';
$locale = 'en_US';
} elseif ($format == 'fb') {
$format = 'EEE, MMM dd yyyy HH:mm:ss ZZZ';
$locale = 'en_US';
}
// Cria a data
$date = new Zend_Date($d, $format, $locale);
$date->setLocale('pt_BR')->setTimezone('America/Sao_Paulo');
if ($date->get('Y') == 0) {
$date->set(date('Y'), 'Y');
}
//echo "<br/><b>$d => " . $date->get('Y') .'</b>';
// Calcula a diferença
$now = time();
$time = $now - $date->getTimestamp();
// Formata a hora
if ($time < 60) {
$time .= ' segundos';
} elseif ($time < 3600) {
//60*60
$time = round(floatval($time) / 60) . ' minutos';
} elseif ($time < 7200) {
//60*60*2
$time = round(floatval($time) / 3660) . ' hora';
} elseif ($time < 86400) {
//60*60*24
$time = round(floatval($time) / 3660) . ' horas';
} elseif ($time < 604800) {
//60*60*24*30
$time = round(floatval($time) / 86400) . ' dias';
} elseif ($time > 1209600 && $time <= 2592000) {
//60*60*24*(7*4)
$time = round(floatval($time) / 604800) . ' semanas';
} elseif ($time > 2592000 && $time <= 5184000) {
//60*60*24*30 && 60*60*24*30*2
$time = round(floatval($time) / 2592000) . ' mês';
} elseif ($time > 5184000 && $time < 31104000) {
//60*60*24*30*2 && 60*60*24*30*12
$time = round(floatval($time) / 2592000) . ' meses';
} else {
//if ($time < 31104000) { //60*60*24*30*12
$time = ' mais de um ano (' . $date->toString() . ')';
}
return $time;
}
示例5: convertDateToStoreTimestamp
public function convertDateToStoreTimestamp($date, $store = null)
{
try {
$dateObj = new Zend_Date();
$dateObj->setTimezone(Mage_Core_Model_Locale::DEFAULT_TIMEZONE);
$dateObj->set($date, Varien_Date::DATETIME_INTERNAL_FORMAT);
$dateObj->setLocale(Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE, $store));
$dateObj->setTimezone(Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE, $store));
$gmtOffset = $dateObj->getGmtOffset();
if ($gmtOffset >= 0) {
return (int) $dateObj->get(null, Zend_Date::TIMESTAMP) + $gmtOffset;
} else {
return (int) $dateObj->get(null, Zend_Date::TIMESTAMP) - $gmtOffset;
}
} catch (Exception $e) {
return null;
}
}
示例6: getAudiences
public function getAudiences($options)
{
$success = true;
$table = Engine_Api::_()->getItemTable('user');
$userTableName = $table->info('name');
$searchTable = Engine_Api::_()->fields()->getTable('user', 'search');
$searchTableName = $searchTable->info('name');
$targetAvailable = $searchTable->info('cols');
$select = $table->select()->from($userTableName)->joinLeft($searchTableName, "`{$searchTableName}`.`item_id` = `{$userTableName}`.`user_id`", null)->where("{$userTableName}.search = ?", 1)->where("{$userTableName}.enabled = ?", 1);
if ($options['birthdate']['min'] == '0') {
$options['birthdate']['min'] = null;
}
if ($options['birthdate']['max'] == '0') {
$options['birthdate']['max'] = null;
}
if ($options['gender'] == '0') {
unset($options['gender']);
}
if ($options['profile_type'] == '0') {
unset($options['profile_type']);
}
if (in_array('city', $targetAvailable)) {
if (!empty($options['cities'])) {
$cities = explode(',', $options['cities']);
$trimmed_cities = array_map('trim', $cities);
unset($options['cities']);
if (count($trimmed_cities)) {
$select->where('city IN (?)', $trimmed_cities);
}
}
}
if (in_array('country', $targetAvailable)) {
if (isset($options['countries'])) {
$countries = $options['countries'];
unset($options['countries']);
if (count($countries)) {
$select->where('country IN (?)', $countries);
}
}
}
if (in_array('interests', $targetAvailable)) {
if ($options['interests']) {
$interests = explode(',', $options['interests']);
$trimmed_interests = array_map('trim', $interests);
unset($options['interests']);
if (count($trimmed_interests)) {
$select->where('interests IN (?)', $trimmed_interests);
}
}
}
if ($options['birthday']) {
$current = new Zend_Date();
$current->setLocale();
$select->where('birthdate = ?', $current->get('YYYY-MM-dd'));
}
if (isset($options['networks'])) {
$networks = $options['networks'];
if (count($networks)) {
$membershipTbl = Engine_Api::_()->getDbtable('membership', 'network');
$membershipTblName = $membershipTbl->info('name');
$users = array();
$newSelect = $membershipTbl->select()->from($membershipTblName, 'user_id')->where('resource_id IN (?)', $networks);
$usersRes = $membershipTbl->fetchAll($newSelect);
$usersRes = $usersRes->toArray();
foreach ($usersRes as $user) {
$users[] = $user['user_id'];
}
if (count($user)) {
$select->where('user_id IN (?)', $users);
} else {
$success = false;
}
}
}
$searchParts = Engine_Api::_()->fields()->getSearchQuery('user', $options);
foreach ($searchParts as $k => $v) {
$select->where("`{$searchTableName}`.{$k}", $v);
}
if ($success) {
$result = $table->fetchAll($select);
return $result;
} else {
return array();
}
}
示例7: testSetLocale
/**
* test setLocale/getLocale
*/
public function testSetLocale()
{
$date = new Zend_Date(0, 'de');
$this->assertSame('de', $date->getLocale());
$date->setLocale('en');
$this->assertSame('en', $date->getLocale());
$date->setLocale('en_XX');
$this->assertSame('en', $date->getLocale());
$date->setLocale('de_AT');
$this->assertSame('de_AT', $date->getLocale());
$locale = new Zend_Locale('ar');
$date->setLocale($locale);
$this->assertSame('ar', $date->getLocale());
try {
$date->setLocale('xx_XX');
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
}
示例8: getDateService
/**
* @return Zend_Date
*/
static function getDateService($date = null)
{
$locale = DevblocksPlatform::getLocaleService();
$date = new Zend_Date($date);
$date->setLocale($locale);
return $date;
}
示例9: testLocale
/**
* Test accessors for _Locale member property of Zend_Date
*/
public function testLocale()
{
$date = new Zend_Date(Zend_Date::now());
$locale = new Zend_Locale('en_Us');
$set = $date->setLocale($locale);
$this->assertSame($date->getLocale(), $set);
}
示例10: indexAction
public function indexAction()
{
if (!$this->_helper->requireUser->isValid()) {
return;
}
$viewer = Engine_Api::_()->user()->getViewer();
$sysTimezone = date_default_timezone_get();
$timezone = Engine_Api::_()->getApi('settings', 'core')->getSetting('core_locale_timezone', 'GMT');
if ($viewer && $viewer->getIdentity() && !empty($viewer->timezone)) {
$timezone = $viewer->timezone;
}
$this->view->timezone = $timezone;
if (null == ($campaign_id = $this->_getParam('campaign_id'))) {
$campaign_id = 0;
}
if (null == ($ad_id = $this->_getParam('ad_id'))) {
$ad_id = 0;
}
if (null == ($export = $this->_getParam('export'))) {
$export = 0;
}
if (null == ($export_type = $this->_getParam('export_type'))) {
$export_type = 'xls';
}
$this->view->form = $form = new Ynsocialads_Form_Report_Filter();
$form->populate($this->_getAllParams());
$values = $form->getValues();
$this->view->formValues = $values;
if ($this->_hasParam('end_date')) {
$end = $this->_getParam('end_date');
if ($end && !is_numeric($end)) {
$end_date = strtotime($end);
} else {
if ($end) {
$end_date = $end;
}
}
$end_date = new Zend_Date($end_date);
} else {
$end_date = new Zend_Date();
}
if ($this->_hasParam('start_date')) {
$start = $this->_getParam('start_date');
if ($start && !is_numeric($start)) {
$start_date = strtotime($start);
} else {
if ($start) {
$start_date = $start;
}
}
$start_date = new Zend_Date($start_date);
} else {
$start_date = new Zend_Date($end_date->getTimestamp());
$start_date->sub(1, 'dd');
}
$form->start_date->setValue($start_date->setLocale()->get('MM/dd/yyyy'));
$form->end_date->setValue($end_date->setLocale()->get('MM/dd/yyyy'));
$end_date->setTimezone($sysTimezone);
$start_date->setTimezone($sysTimezone);
$campaignTbl = Engine_Api::_()->getItemTable('ynsocialads_campaign');
$select = $campaignTbl->select()->where('user_id = ?', $viewer->getIdentity());
$campaigns = $campaignTbl->fetchAll($select);
foreach ($campaigns as $campaign) {
$form->campaign_id->addMultiOption($campaign['campaign_id'], $campaign['title']);
}
$form->campaign_id->setValue($campaign_id);
$adTbl = Engine_Api::_()->getDbtable('ads', 'ynsocialads');
$adTotal = array();
if ($campaign_id == 0) {
$form->ad_id->setAttrib('disabled', 'disabled');
foreach ($campaigns as $campaign) {
$adList = $adTbl->fetchAll($adTbl->select()->where('campaign_id = ?', $campaign['campaign_id']));
foreach ($adList as $ad) {
$adTotal[] = $ad->ad_id;
}
}
} else {
$ads = $adTbl->fetchAll($adTbl->select('ad_id')->where('campaign_id = ?', $campaign_id));
foreach ($ads as $ad) {
$form->ad_id->addMultiOption($ad['ad_id'], $ad['name']);
if ($ad_id == 0) {
array_push($adTotal, $ad['ad_id']);
}
}
if ($ad_id != 0) {
$adTotal = array($ad_id);
}
$form->ad_id->setValue($ad_id);
}
$staTable = Engine_Api::_()->getDbtable('tracks', 'ynsocialads');
$staName = $staTable->info('name');
$select = $staTable->select();
$select->where('ad_id IN (?)', $adTotal)->where('date >= ?', $start_date->get('yyyy-MM-dd'))->where('date <= ?', $end_date->get('yyyy-MM-dd'))->order('ad_id ASC');
if (count($adTotal)) {
$tracks = $staTable->fetchAll($select);
} else {
$tracks = array();
}
if ($export == 0) {
$page = $this->_getParam('page', 1);
//.........这里部分代码省略.........
示例11: dirname
#!/usr/bin/php
<?php
require_once dirname(__FILE__) . '/../../common.php';
$date = new Zend_Date();
$date->setLocale(LOCALE);
$phpLiveDocx = new Tis_Service_LiveDocx_MailMerge(USERNAME, PASSWORD);
$phpLiveDocx->setLocalTemplate('template.docx');
$phpLiveDocx->assign('software', 'ACE Downloader 2.8');
$phpLiveDocx->assign('licensee', 'Paul Peterson');
$phpLiveDocx->assign('company', 'Bresoft Ltd');
$phpLiveDocx->assign('date', $date->get(Zend_Date::DATE_LONG));
$phpLiveDocx->assign('time', $date->get(Zend_Date::TIME_LONG));
$phpLiveDocx->assign('city', 'Royal Tunbridge Wells');
$phpLiveDocx->assign('country', 'United Kingdom');
$phpLiveDocx->createDocument();
foreach ($phpLiveDocx->getDocumentFormats() as $format) {
$documentFile = sprintf('document.%s', $format);
printf('Retrieving %s version (%s)... ', strtoupper($format), $documentFile);
$document = $phpLiveDocx->retrieveDocument($format);
file_put_contents($documentFile, $document);
print "DONE.\n";
}
unset($phpLiveDocx);
示例12: getDate
public function getDate()
{
$dateObj = new Zend_Date($this->getCreatedAt(), Zend_Date::ISO_8601);
$dateObj->setLocale(Mage::app()->getLocale()->getLocaleCode());
return $dateObj->toString(Zend_Date::DATETIME_MEDIUM);
}
示例13: localDate
function localDate($date, $lang)
{
$date = new Zend_Date($date);
$date->setLocale($lang);
return $date->toString(Zend_Date::DATE_FULL);
}