本文整理汇总了PHP中Zend_Date::subDay方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Date::subDay方法的具体用法?PHP Zend_Date::subDay怎么用?PHP Zend_Date::subDay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Date
的用法示例。
在下文中一共展示了Zend_Date::subDay方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexAction
public function indexAction()
{
// numero da semana anterior
$zendDate = new Zend_Date();
$semana = $zendDate->get(Zend_Date::WEEK) - 1;
$dia_semana = $zendDate->get(Zend_Date::WEEKDAY_DIGIT);
$zendDate->subDay(7);
$dia_semana_inicio = $dia_semana - 1;
$dia_semana_fim = 7 - $dia_semana;
$periodo_inicial = $zendDate->subDay($dia_semana_inicio)->get("dd/MM/YYYY");
$periodo_final = $zendDate->addDay($dia_semana_fim)->get('dd/MM/YYYY');
$periodo = $periodo_inicial . ' à ' . $periodo_final;
// busca as visualizacoes da semana
$modelSalaoVisualizacao = new Model_DbTable_SalaoVisualizacao();
$visualizacoes = $modelSalaoVisualizacao->visualizacoes($semana);
try {
foreach ($visualizacoes as $visualizacao) {
$pluginMail = new Plugin_Mail();
$pluginMail->setDataMail('visualizacao', $visualizacao);
$pluginMail->setDataMail('periodo', $periodo);
$pluginMail->send("salao-visualizacao.phtml", "Relatório de Visualizações", $visualizacao->salao_email);
}
echo 'emails enviados';
} catch (Zend_Mail_Exception $ex) {
die('email');
} catch (Exception $ex) {
Zend_Debug::dump($ex->getMessage());
}
}
示例2: myBest
/**
* Retrieve Bestseller product to show in frontend
* @return mixed
*/
public function myBest()
{
$storeId = Mage::app()->getStore()->getId();
$HandleArray = Mage::app()->getLayout()->getUpdate()->getHandles();
$CategoryHandle = 'catalog_category_view';
$SourceConfig = Mage::getStoreConfig('sm_bestseller/sm_bestseller_source');
if ($SourceConfig && !empty($SourceConfig)) {
$SourceType = $SourceConfig['timeperiod'];
$date = new Zend_Date();
/**
* Select time range to retrive bestseller
*/
if ($SourceType && $SourceType == 'specify') {
$fromDate = $date->setDate($SourceConfig['fromdate'])->get('Y-MM-dd');
$toDate = $date->setDate($SourceConfig['todate'])->get('Y-MM-dd');
} else {
/**
* use switch to return begin of week, month, year...
*/
switch ($SourceType) {
case 'subWeek':
$toDate = $date->subDay($date->getDate()->get('e'))->getDate()->get('Y-MM-dd');
break;
case 'subMonth':
$toDate = $date->setDay(1)->getDate()->get('Y-MM-dd');
break;
case 'subYear':
$toDate = $date->subDay($date->getDate()->get('D'))->getDate()->get('Y-MM-dd');
break;
default:
$toDate = $date->getDate()->get('Y-MM-dd');
}
// end switch
$subType = $SourceType;
$unit = $SourceConfig['unit'] ? $SourceConfig['unit'] : 1;
$fromDate = $date->{$subType}($unit)->getDate()->get('Y-MM-dd');
}
// end else
/**
* Limit maximum product retrieve
*/
$limit = $SourceConfig['limitproduct'];
if ($limit > 0 && ctype_digit($limit)) {
$this->setProductsCount($limit);
}
$products = Mage::getResourceModel('reports/product_collection')->addOrderedQty($fromDate, $toDate)->addAttributeToSelect('*')->addAttributeToSelect(array('name', 'price', 'small_image'))->setStoreId($storeId)->addStoreFilter($storeId)->setOrder('ordered_qty', 'desc');
// most best sellers on top
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
$products->setPageSize($limit)->setCurPage(1);
if (in_array($CategoryHandle, $HandleArray)) {
$CategoryId = Mage::getModel('catalog/layer')->getCurrentCategory()->getId();
$CategoryModel = Mage::getModel('catalog/category')->load($CategoryId);
$products->addCategoryFilter($CategoryModel);
}
return $products;
}
// end if sourceconfig
}
示例3: testNetwork
/**
* Test the network provided
* @param $affiliateNetwork
* @return none
*/
public static function testNetwork($network)
{
//Start date, the first two months ago
$startDate = new Zend_Date();
$startDate->setDay(1);
$startDate->subMonth(2);
$startDate->setHour(00);
$startDate->setMinute(00);
$startDate->setSecond(00);
//Yesterday, some networks don't give us the data for the same day, then is the safer way to have our data
$endDate = new Zend_Date();
$endDate->subDay(1);
$endDate->setHour(23);
$endDate->setMinute(59);
$endDate->setSecond(59);
//are we connected?
if ($network->checkConnection()) {
//Get all the payments for this network.
$paymentsList = $network->getPaymentHistory();
echo "Total Number of payments: " . count($paymentsList) . "\n\n";
//Get all the Merhcants
$merchantList = $network->getMerchantList(array());
echo "Number of merchants: " . count($merchantList) . "\n\n";
// Building the array of merchant Id we want to retrieve data from.
$merchantIdList = array();
foreach ($merchantList as $merchant) {
$merchantIdList[] = $merchant['cid'];
}
//If we have joined any merchant
if (!empty($merchantIdList)) {
//Split the dates monthly, Most of the network don't allow us to retrieve more than a month data
$dateArray = Oara_Utilities::monthsOfDifference($startDate, $endDate);
for ($i = 0; $i < count($dateArray); $i++) {
// Calculating the start and end date for the current month
$monthStartDate = clone $dateArray[$i];
$monthEndDate = null;
if ($i != count($dateArray) - 1) {
$monthEndDate = clone $dateArray[$i];
$monthEndDate->setDay(1);
$monthEndDate->addMonth(1);
$monthEndDate->subDay(1);
} else {
$monthEndDate = $endDate;
}
$monthEndDate->setHour(23);
$monthEndDate->setMinute(59);
$monthEndDate->setSecond(59);
echo "\n importing from " . $monthStartDate->toString("dd-MM-yyyy HH:mm:ss") . " to " . $monthEndDate->toString("dd-MM-yyyy HH:mm:ss") . "\n";
$transactionList = $network->getTransactionList($merchantIdList, $monthStartDate, $monthEndDate);
echo "Number of transactions: " . count($transactionList) . "\n\n";
$overviewList = $network->getOverviewList($transactionList, $merchantIdList, $monthStartDate, $monthEndDate);
echo "Number register on the overview: " . count($overviewList) . "\n\n";
}
}
echo "Import finished \n\n";
} else {
echo "Error connecting to the network, check credentials\n\n";
}
}
示例4: addOldLockedFilter
public function addOldLockedFilter()
{
$today = new Zend_Date();
$today->subDay(3);
$oldDateTimeString = $today->toString(AW_Core_Model_Abstract::DB_DATETIME_FORMAT);
$this->getSelect()->where("is_locked>0 AND lock_changed_date<'" . $oldDateTimeString . "'");
return $this;
}
示例5: getOldPromotions
public function getOldPromotions($subDay = 30)
{
$date = new Zend_Date();
$now = $date->toString('y-MM-dd');
$date->subDay($subDay);
$before = $date->toString('y-MM-dd');
$where = join(' AND ', array($this->_db->quoteInto('end_at < ?', $now), $this->_db->quoteInto('end_at > ?', $before)));
return $this->fetchAll($where);
}
示例6: cleanHistory
public function cleanHistory()
{
$date = new Zend_Date();
$date->subDay(3);
$collection = Mage::getModel('feedexport/feed_history')->getCollection()->addFieldToFilter('created_at', array('lt' => $date->toString('Y-MM-dd H:mm:s')));
foreach ($collection as $entry) {
$entry->delete();
}
return $this;
}
示例7: isLocked
public function isLocked()
{
if (!$this->getId() or $this->getNumberOfError() < 3) {
return false;
}
$lastError = $this->getLastError();
$now = new Zend_Date();
$yesterday = $now->subDay(1)->toString('y-MM-dd HH:mm:ss');
return $lastError > $yesterday;
}
示例8: checkConnection
/**
* Check the connection
*/
public function checkConnection()
{
//If not login properly the construct launch an exception
$connection = true;
$yesterday = new \Zend_Date();
$yesterday->subDay(2);
$urls = array();
$urls[] = new Oara_Curl_Request("https://publisher.ebaypartnernetwork.com/PublisherReportsTx?pt=2&start_date={$yesterday->toSTring("M/d/yyyy")}&end_date={$yesterday->toSTring("M/d/yyyy")}&user_name={$this->_credentials['user']}&user_password={$this->_credentials['password']}&advIdProgIdCombo=&tx_fmt=2&submit_tx=Download", array());
$exportReport = $this->_client->get($urls);
if (preg_match("/DOCTYPE html PUBLIC/", $exportReport[0])) {
$connection = false;
}
return $connection;
}
示例9: isValid
public function isValid($startDay)
{
$start = (string) $startDay;
// If start day is empty return true, Campaings-model set this day
if (empty($start)) {
return true;
} else {
$start = new Zend_Date($start, Zend_Date::ISO_8601);
}
$this->_setValue($start);
$thisDay = date("Y-m-d", time());
$thisDay = new Zend_Date($thisDay, Zend_Date::ISO_8601);
$thisDay->subDay(1);
if ($start->compare($thisDay) == 1) {
return true;
}
$this->_error(self::NOT_MATCH);
return false;
}
示例10: isValid
public function isValid($endDay, $startDay = null)
{
$end = (string) $endDay;
// If end day is empty return true, Campaings-model set 0000-00-00
if (empty($end) || $end == '0000-00-00') {
return true;
} else {
$end = new Zend_Date($end, Zend_Date::ISO_8601);
}
$this->_setValue($end);
/* context is an array with the entire set of form values in our case,
* the value we are interested in is $context["$this->dateField"],
* (start day field) which should before as $value (end date field)
*/
if (is_array($startDay)) {
if (isset($startDay["{$this->dateField}"])) {
// If start day is empty, set this day
if (empty($startDay["{$this->dateField}"])) {
$start = date("Y-m-d", time());
} else {
$start = $startDay["{$this->dateField}"];
}
$start = new Zend_Date($start, Zend_Date::ISO_8601);
if ($end->compare($start) == 1) {
return true;
}
} else {
// If admin is editing started campaign check that new end date is this day or after
$thisDay = date("Y-m-d", time());
$thisDay = new Zend_Date($thisDay, Zend_Date::ISO_8601);
$thisDay->subDay(1);
if ($end->compare($thisDay) == 1) {
return true;
}
}
}
$this->_error(self::NOT_MATCH);
return false;
}
示例11: getPredefinedRange
/**
* 取得某个预定义时间段
*
* @static
* @param integer $interval
* @param string $forceUnit
* @param integer $timestamp
* @return array
*/
public static function getPredefinedRange($interval, $forceUnit = null, $timestamp = null)
{
if (empty($timestamp)) {
$timestamp = time();
}
$start = new Zend_Date($timestamp);
$end = new Zend_Date($timestamp);
switch ($interval) {
case self::TODAY:
$start->setHour(0)->setMinute(0)->setSecond(0);
$unit = Zend_Date::HOUR;
break;
case self::YESTODAY:
$start->subDay(1)->setHour(0)->setMinute(0)->setSecond(0);
$end = clone $start;
$end->addDay(1);
$unit = Zend_Date::HOUR;
break;
case self::TOMORROW:
$start->addDay(1)->setHour(0)->setMinute(0)->setSecond(0);
$end = clone $start;
$end->addDay(1);
$unit = Zend_Date::HOUR;
break;
case self::THIS_MONTH:
$start->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
$unit = Zend_Date::DAY;
break;
case self::THIS_YEAR:
$start->setMonth(1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
$end->addMonth(1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
$unit = Zend_Date::DAY;
break;
case self::THIS_SEASON:
$start->setMonth(3 * floor(($start->toValue('M') - 1) / 3) + 1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
$unit = Zend_Date::DAY;
case self::RECENT_24HOUR:
$start->subHour(24);
$unit = Zend_Date::HOUR;
break;
case self::RECENT_48HOUR:
$start->subHour(48);
$unit = Zend_Date::HOUR;
break;
case self::RECENT_1WEEK:
$start->subWeek(1);
$unit = Zend_Date::DAY;
break;
case self::RECENT_1MONTH:
$start->subMonth(1);
$unit = Zend_Date::DAY;
break;
case self::RECENT_24MONTH:
$start->subMonth(24);
$unit = Zend_Date::DAY;
break;
case self::LAST_1MONTH:
$start->subMonth(1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
$end = clone $start;
$end->addMonth(1);
$unit = Zend_Date::DAY;
break;
case self::LAST_1YEAR:
$start->subYear(1)->setMonth(1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
$end = clone $start;
$end->addYear(1);
$unit = Zend_Date::DAY;
break;
case self::ENTIRE_DAY:
$start->setDate(self::ERA_DATE, self::ZF_DATE_FORMAT)->setTime(self::ERA_TIME, self::ZF_TIME_FORMAT);
$end->addDay(1);
$unit = Zend_Date::DAY;
break;
default:
$unit = Zend_Date::SECOND;
}
if (!empty($forceUnit)) {
$unit = $forceUnit;
}
$start = max(self::truncateDatetime($start, $unit), self::truncateDatetime(self::ERA_DATETIME, $unit));
$end = max(self::truncateDatetime($end, $unit), self::truncateDatetime(self::ERA_DATETIME, $unit));
return compact('start', 'end', 'unit');
}
示例12: listFilesAction
/**
* Display the list of the importation files
* Initiates actions for import and export of data.
*
* @return void
*/
public function listFilesAction()
{
if ($this->view->aclIsAllowed($this->_moduleTitle, 'edit', true)) {
$this->_findCsvFiles('list');
$tables = array('FilesImport' => array('FI_ID', 'FI_FileName', 'FI_LastModif', 'FI_LastAccess'));
$field_list = array('FI_ID' => array('width' => '50px'), 'FI_LastModif' => array('width' => '150px'), 'FI_LastAccess' => array('width' => '150px'));
if ($this->_importType) {
$field_list['FI_Type'] = array('width' => '50px');
}
$this->view->params = $this->_getAllParams();
$pageID = $this->_getParam('pageID');
$langId = $this->_registry->languageID;
$lines = new ImportExportObject();
$select = $lines->getAllByType($langId, $this->_importType);
$oDate = new Zend_Date(time());
$validDate = $oDate->subDay($this->_interval, Zend_Date::DAY);
$validDate = $oDate->toString('Y-M-d H:m:s');
$options = array('commands' => array($this->view->link($this->view->url(array('controller' => $this->_name, 'action' => $this->_defaultAction)), $this->view->getCibleText('button_import_all'), array('class' => 'action_submit import'))), 'disable-export-to-excel' => $this->_exportExcel, 'disable-export-to-pdf' => $this->_exportPdf, 'disable-export-to-csv' => $this->_exportCsv, 'filters' => array('max_days_interval' => array('label' => 'Filtre 1', 'default_value' => $validDate, 'associatedTo' => 'FI_LastModif', 'whereClause' => ' > ', 'choices' => array('' => '', 'isvalid' => $this->view->getCibleText('filter_files_to_import')))), 'action_panel' => array('width' => '50', 'actions' => array('import' => array('label' => $this->view->getCibleText('button_import'), 'url' => $this->view->baseUrl() . "/" . $this->_moduleTitle . "/" . $this->_name . "/" . $this->_defaultAction . "/" . $this->_paramId . "/%ID%/" . $pageID, 'findReplace' => array('search' => '%ID%', 'replace' => 'FI_ID')))));
$mylist = new Cible_Paginator($select, $tables, $field_list, $options);
$this->view->assign('mylist', $mylist);
}
}
示例13: getInterval
/**
* Return interval (two GMT Zend_Date).
*
* @param $code
* @param bool $timezone
*
* @return Varien_Object
*/
public function getInterval($code, $timezone = false)
{
$timestamp = Mage::getSingleton('core/date')->gmtTimestamp();
if ($timezone) {
$timestamp = Mage::app()->getLocale()->date($timestamp);
}
$from = new Zend_Date($timestamp, null, Mage::app()->getLocale()->getLocaleCode());
$to = clone $from;
$dateInterval = null;
switch ($code) {
case self::TODAY:
$from->setTime('00:00:00');
$to->setTime('23:59:59');
break;
case self::YESTERDAY:
$from->subDay(1)->setTime('00:00:00');
$to->subDay(1)->setTime('23:59:59');
break;
case self::THIS_MONTH:
$from->setDay(1)->setTime('00:00:00');
$to->setDay(1)->addDay($to->get(Zend_Date::MONTH_DAYS) - 1)->setTime('23:59:59');
break;
case self::PREVIOUS_MONTH:
$from->setDay(1)->subMonth(1)->setTime('00:00:00');
$to->setDay(1)->setTime('23:59:59')->subMonth(1)->addDay($to->get(Zend_Date::MONTH_DAYS) - 1);
break;
case self::THIS_QUARTER:
$month = intval($from->get(Zend_Date::MONTH) / 4) * 3 + 1;
$from->setDay(1)->setMonth($month)->setTime('00:00:00');
$to->setDay(1)->setMonth($month)->addMonth(3)->subDay(1)->setTime('23:59:59');
break;
case self::PREVIOUS_QUARTER:
$month = intval($from->get(Zend_Date::MONTH) / 4) * 3 + 1;
$from->setDay(1)->setMonth($month)->setTime('00:00:00')->subMonth(3);
$to->setDay(1)->setMonth($month)->addMonth(3)->subDay(1)->setTime('23:59:59')->subMonth(3);
break;
case self::THIS_YEAR:
$from->setDay(1)->setMonth(1)->setTime('00:00:00');
$to->setDay(1)->setMonth(1)->addDay($to->get(Zend_Date::LEAPYEAR) ? 365 : 364)->setTime('23:59:59');
break;
case self::PREVIOUS_YEAR:
$from->setDay(1)->setMonth(1)->setTime('00:00:00')->subYear(1);
$to->setDay(1)->setMonth(1)->addDay($to->get(Zend_Date::LEAPYEAR) ? 365 : 364)->setTime('23:59:59')->subYear(1);
break;
case self::LAST_24H:
$from->subDay(1);
break;
case self::THIS_WEEK:
$weekday = $from->get(Zend_Date::WEEKDAY_DIGIT);
#0-6
$from->setTime('00:00:00')->subDay($weekday);
$to->setTime('23:59:59')->addDay(6 - $weekday);
break;
case self::PREVIOUS_WEEK:
$weekday = $from->get(Zend_Date::WEEKDAY_DIGIT);
#0-6
$from->setTime('00:00:00')->subDay($weekday)->subWeek(1);
$to->setTime('23:59:59')->addDay(6 - $weekday)->subWeek(1);
break;
case self::LAST_7D:
$from->subDay(7);
break;
case self::LAST_30D:
$from->subDay(30);
break;
case self::LAST_3M:
$from->subMonth(3);
break;
case self::LAST_12M:
$from->subYear(1);
break;
case self::LIFETIME:
$from->subYear(10);
$to->addYear(10);
break;
}
return new Varien_Object(array('from' => $from, 'to' => $to));
}
示例14: testLoose
//.........这里部分代码省略.........
// success
}
try {
$date->addMonth(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->subMonth(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->compareMonth(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->setDay(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->addDay(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->subDay(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->compareDay(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->setWeekday(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->addWeekday(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->subWeekday(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->compareWeekday(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
示例15: testYesterday
/**
* Test for Yesterday
*/
public function testYesterday()
{
$locale = new Zend_Locale('de_AT');
$date = new Zend_Date(Zend_Date::now());
$d2 = new Zend_Date(1010101010, $locale);
$date->subDay(1);
$this->assertFalse($d2->isYesterday());
$this->assertTrue($date->isYesterday());
}