本文整理汇总了PHP中Zend_Date::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Date::add方法的具体用法?PHP Zend_Date::add怎么用?PHP Zend_Date::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Date
的用法示例。
在下文中一共展示了Zend_Date::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setSubscription
/**
* Save subscription to RDMBS
*
* @param array $data
* @return bool
*/
public function setSubscription(array $data)
{
if (!isset($data['id'])) {
require_once 'Zend/Feed/Pubsubhubbub/Exception.php';
throw new Zend_Feed_Pubsubhubbub_Exception(
'ID must be set before attempting a save'
);
}
$result = $this->_db->find($data['id']);
if (count($result)) {
$data['created_time'] = $result->current()->created_time;
$now = new Zend_Date;
if (isset($data['lease_seconds'])) {
$data['expiration_time'] = $now->add($data['lease_seconds'], Zend_Date::SECOND)
->get('yyyy-MM-dd HH:mm:ss');
}
$this->_db->update(
$data,
$this->_db->getAdapter()->quoteInto('id = ?', $data['id'])
);
return false;
}
$this->_db->insert($data);
return true;
}
示例2: saveBilling
/**
* Checks the legal age
*
* @param array $data
* @param int $customerAddressId
* @return Mage_Checkout_Model_Type_Onepage
*/
public function saveBilling($data, $customerAddressId)
{
$result = parent::saveBilling($data, $customerAddressId);
if (isset($result['error'])) {
return $result;
}
$dobIso = $this->getQuote()->getCustomerDob();
$dob = new Zend_Date($dobIso, Zend_Date::ISO_8601);
$legalBirthDay = $dob->add(self::LIMITED_AGE, Zend_Date::YEAR);
$legal1 = Zend_Date::now()->isLater($legalBirthDay);
if (!$legal1) {
// not even limited legal
$result['error'] = 1;
$result['message'] = Mage::helper('n98legalage')->__('You are not yet limited contractually capable. You can ask your legal guardian to purchase.');
return $result;
}
$dob = new Zend_Date($dobIso, Zend_Date::ISO_8601);
$legalBirthDay = $dob->add(self::LEGAL_AGE, Zend_Date::YEAR);
$legal2 = Zend_Date::now()->isLater($legalBirthDay);
if (!$legal2) {
$result['error'] = 1;
$result['message'] = Mage::helper('n98legalage')->__('You are not yet contractually capable. You can ask your legal guardian to purchase on your behalf.');
return $result;
}
return $result;
}
示例3: indexAction
/**
* Enter description here...
*
*/
public function indexAction()
{
$currentDate = new Zend_Date();
$currentMonth = $currentDate->toString(Zend_Date::MONTH_SHORT);
$currentDay = $currentDate->toString(Zend_Date::DAY_SHORT);
$month = $this->_getParam('month', $currentMonth);
if (false === is_numeric($month)) {
$month = $this->_monthMap[urldecode($month)];
}
$currentDate->setMonth($month);
$currentDate->setDay(1);
$days = $currentDate->toString(Zend_Date::MONTH_DAYS);
$this->view->selectedMonth = $month;
$this->view->currentMonth = $currentMonth;
$this->view->currentDay = $currentDay;
$result = Bc_UserDTO::fetchAsArray(array('month' => $month));
$month = array();
for ($i = 1; $i <= $days; $i++) {
$data = array();
$data['date'] = $currentDate->toString(Zend_Date::DAY . '.' . Zend_Date::MONTH . '.' . Zend_Date::YEAR);
$user = array();
foreach ($result as $birthday) {
if ($i == $birthday['birthday']) {
$user[] = $birthday;
}
}
$data['user'] = empty($user) ? null : $user;
$month[$i] = $data;
$currentDate->add('24:00:00', Zend_Date::TIMES);
}
$this->view->month = $month;
}
示例4: generateInvoiceAction
public function generateInvoiceAction()
{
if ($this->getRequest()->isGet()) {
$sessionid = $this->_getParam('id');
$config = new Zend_Config_Ini(APPLICATION_PATH . '/forms/session.ini', 'invoice');
$this->view->form = new Zend_Form($config->session);
$this->view->form->sessionid->setValue($sessionid);
} else {
if ($this->getRequest()->isPost()) {
$inv = new Model_Invoice();
$date = new Zend_Date();
$inv->generationdate = $date->get(Zend_Date::W3C);
$duedate = $date->add($this->_getParam('daystopay'), Zend_Date::DAY);
$inv->duedate = $duedate->get(Zend_Date::W3C);
$inv->amount = $this->_getParam('amount');
$inv->save();
$session = Model_Session::findOneById($this->_getParam('id'));
$session->invoiceid = $inv->id;
$session->save();
$this->_redirect('/admin/');
} else {
$this->_redirect('/admin/');
}
}
}
示例5: checkDateConstraint
public static function checkDateConstraint($dateTime, $limit)
{
$dateStr = $dateTime->format('Y-m-d H:i:s');
$date = new Zend_Date($dateStr, 'yyyy-MM-dd HH:mm:ss');
$now = new Zend_Date();
$date->add($limit, Zend_Date::DAY);
return $date->isLater($now);
}
示例6: manipulatDate
/**
* manipulate data and output to a string.
*
* @param $date
* @param $offset
* @param $measure
* @return string
*/
public function manipulatDate($date, $offset, $measure)
{
date_default_timezone_set('Europe/Stockholm');
$sql_date_pattern = 'yyyy-MM-dd HH:mm:ss';
$date_obj = new Zend_Date($date, $sql_date_pattern);
$date_obj->add($offset, $measure);
$current_time = $date_obj->get($sql_date_pattern);
return $current_time;
}
示例7: dateAdd
/**
* This uses the zend framwork date add function.
* Good for adding a number of days to a date.
*
* @param string $datestring MySQL formatted Date String Y-m-d.
* @param string number of days to be added.
* @return string result date formatted as a MySQL Date Y-m-d.
*/
public function dateAdd($datestring, $numberofdays = 1)
{
$dateEl = explode("-", $datestring);
$datearray = array('year' => date($dateEl[0]), 'month' => date($dateEl[1]), 'day' => date($dateEl[2]));
$zenddate = new Zend_Date($datearray);
$zenddate->add($numberofdays, Zend_Date::DAY_SHORT);
$dateVal = $zenddate->toString('Y-m-d');
return $dateVal;
}
示例8: sourceRecords
/**
* @param array $params
*
* @return SS_List
*/
public function sourceRecords($params = array())
{
Versioned::reading_stage("Stage");
$records = SiteTree::get();
$compatibility = ContentReviewCompatability::start();
if (empty($params["ReviewDateBefore"]) && empty($params["ReviewDateAfter"])) {
// If there's no review dates set, default to all pages due for review now
$reviewDate = new Zend_Date(SS_Datetime::now()->Format("U"));
$reviewDate->add(1, Zend_Date::DAY);
$records = $records->where(sprintf('"NextReviewDate" < \'%s\'', $reviewDate->toString("YYYY-MM-dd")));
} else {
// Review date before
if (!empty($params['ReviewDateBefore'])) {
// TODO Get value from DateField->dataValue() once we have access to form elements here
$reviewDate = new Zend_Date($params["ReviewDateBefore"], Config::inst()->get("i18n", "date_format"));
$reviewDate->add(1, Zend_Date::DAY);
$records = $records->where(sprintf("\"NextReviewDate\" < '%s'", $reviewDate->toString("YYYY-MM-dd")));
}
// Review date after
if (!empty($params["ReviewDateAfter"])) {
// TODO Get value from DateField->dataValue() once we have access to form elements here
$reviewDate = new Zend_Date($params["ReviewDateAfter"], Config::inst()->get("i18n", "date_format"));
$records = $records->where(sprintf("\"NextReviewDate\" >= '%s'", $reviewDate->toString("YYYY-MM-dd")));
}
}
// Show virtual pages?
if (empty($params["ShowVirtualPages"])) {
$virtualPageClasses = ClassInfo::subclassesFor("VirtualPage");
$records = $records->where(sprintf("\"SiteTree\".\"ClassName\" NOT IN ('%s')", implode("','", array_values($virtualPageClasses))));
}
// Owner dropdown
if (!empty($params["ContentReviewOwner"])) {
$ownerNames = Convert::raw2sql($params["ContentReviewOwner"]);
$records = $records->filter("OwnerNames:PartialMatch", $ownerNames);
}
// Only show pages assigned to the current user?
// This come last because it transforms $records to an ArrayList.
if (!empty($params["OnlyMyPages"])) {
$currentUser = Member::currentUser();
$records = $records->filterByCallback(function ($page) use($currentUser) {
$options = $page->getOptions();
foreach ($options->ContentReviewOwners() as $owner) {
if ($currentUser->ID == $owner->ID) {
return true;
}
}
return false;
});
}
ContentReviewCompatability::done($compatibility);
return $records;
}
示例9: weeklystatsAction
public function weeklystatsAction()
{
$this->disableLayout();
$this->disableViewAutoRender();
$type = $this->getParam('type');
$end = new Zend_Date();
$end->setTime('23:59:59');
$date = new Zend_Date();
$date->sub(6, Zend_Date::DAY);
$date->setTime('00:00:01');
//Build reference array
$i = 0;
//echo $end->getTimestamp(); echo "<br>";
while ($i <= 6) {
$referencearray[$date->get('dd-MM-YYYY')] = 0;
$date->add(1, Zend_Date::DAY);
$i++;
}
//Get the results array
$start = new Zend_date();
$start->sub(6, Zend_Date::DAY);
$start->setTime('00:00:01');
$stat = new \Object\Stats();
$results = $stat->getStatistics($this->selectedLocation->getId(), $start, $end);
$startoftheweek = $start->get('dd-MM-YYYY');
//echo $start->getTimestamp(); echo "<br>";exit;
foreach ($this->selectedLocation->getServings() as $serving) {
//initiate orderarray and seatsarray
$orderarray = $referencearray;
$seatsarray = $referencearray;
foreach ($results as $result) {
$datein = date("d-m-Y", $result["date_start"]);
if ($serving->getId() == $result['serving_id']) {
$servingid = $result['serving_id'];
if (array_key_exists($datein, $referencearray)) {
$orderarray[$datein] = $result["nbre"];
$seatsarray[$datein] = $result["couverts"];
}
}
}
if ($type == 'seats') {
$servingarray[$serving->getTitle()] = $seatsarray;
} else {
$servingarray[$serving->getTitle()] = $orderarray;
}
}
$reponse = new Reponse();
$reponse->data = $servingarray;
$reponse->message = "TXT_STATS_SENT";
$reponse->success = true;
$this->render($reponse);
}
示例10: add
public function add($date, $part = null, $locale = null)
{
if ($date instanceof Period) {
// now you've got to love that irony
// because period actually returns a new date object (the world how it's supposed to be)
// we can't do much with the result anyhow
// and have to actually set the resulting (new) date as this date
// cool, isn't it?
$newSelf = $date->addToDate($this);
return $this->set($newSelf);
} else {
return parent::add($date, $part, $locale);
}
}
示例11: meta
/** Display meta data
*
* @param string $keywords
* @uses Pas_View_Helper_CurUrl
* @uses Zend_View_Helper_PartialLoop
* @uses Zend_View_Helper_HeadMeta
* @uses Pas_View_Helper_Title
*
*/
public function meta()
{
$date = new Zend_Date();
$date->add('72', Zend_Date::HOUR);
$this->view->headMeta()->appendHttpEquiv('expires', $date->get(Zend_Date::RFC_1123))->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8')->appendHttpEquiv('Content-Language', 'en-GB')->appendHttpEquiv('imagetoolbar', 'no');
$this->view->headMeta($this->view->partialLoop('partials/database/author.phtml', $this->view->peoples), 'dc.creator');
$this->view->headMeta($this->view->CurUrl(), 'dc.identifier');
$this->view->headMeta($this->view->title(), 'dc.title');
$this->view->headMeta($keywords, 'dc.keywords');
$this->view->headMeta('The Portable Antiquities Scheme and the British Museum', 'dc.publisher');
$this->view->headMeta(strip_tags($this->view->partialLoop('partials/database/description.phtml', $this->view->finds)), 'dc.description');
$this->view->headMeta($this->view->partialLoop('partials/database/datecreated.phtml', $this->view->finds), 'dc.date.created');
$this->view->headMeta('Archaeological artefact found in England or Wales', 'dc.subject');
}
示例12: metaBasic
function metaBasic()
{
$date = new Zend_Date();
$date->add('72', Zend_Date::HOUR);
$this->view->headMeta()->appendHttpEquiv('expires', $date->get(Zend_Date::RFC_1123))->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8')->appendHttpEquiv('Content-Language', 'en-GB')->appendHttpEquiv('imagetoolbar', 'no');
$this->view->headMeta('Daniel Pett', 'DC.Creator');
$this->view->headMeta($this->CurUrl(), 'DC.Identifier');
$this->view->headMeta($this->title(), 'DC.Title');
$this->view->headMeta('basic,search,what,where,when,portable antiquities', 'DC.Keywords');
$this->view->headMeta('The Portable Antiquities Scheme and the British Museum', 'DC.Publisher');
$this->view->headMeta('Search the Portable Antiquities Scheme Database using our basic what where when search interface.', 'DC.Description');
$this->view->headMeta('', 'DC.date.created');
$this->view->headMeta('Archaeology', 'DC.subject');
}
示例13: _data
protected function _data()
{
$model = new Application_Model_Encontro();
$sessao = Zend_Auth::getInstance()->getIdentity();
$where = $model->getAdapter()->quoteInto('id_encontro = ?', $sessao["idEncontro"]);
$row = $model->fetchRow($where);
$element = $this->createElement('radio', 'data', array('label' => 'Data: '));
$data_ini = new Zend_Date($row->data_inicio);
$data_fim = new Zend_Date($row->data_fim);
while ($data_ini <= $data_fim) {
$element->addMultiOption($data_ini->toString('dd/MM/YYYY'), $data_ini->toString('dd/MM/YYYY'));
$data_ini->add(1, Zend_Date::DAY);
}
$element->setRequired(true)->addErrorMessage("Escolha uma data para realização do evento");
$element->setDecorators(array('ViewHelper', 'Description', 'Errors', array('HtmlTag', ''), array('Label', '')));
return $element;
}
示例14: showTracking
/**
* Check if data transfer is activated and if enough time has passed since the last request
*
* @return bool
*/
public function showTracking()
{
if (!Mage::getStoreConfig('germanstoreconfig/installation_id')) {
return false;
}
if (Mage::getStoreConfig('admin/germanstoreconfig/datatransfer') == IntegerNet_GermanStoreConfig_Model_Source_Datatransfer::DATATRANSFER_NONE) {
return false;
}
$lastTransferDate = Mage::getStoreConfig('germanstoreconfig/transfer_date');
if (!$lastTransferDate) {
return true;
}
date_default_timezone_set(Mage::getStoreConfig('general/locale/timezone'));
$lastTransferDateObject = new Zend_Date();
$lastTransferDateObject->set($lastTransferDate, Zend_Date::ISO_8601);
return $lastTransferDateObject->add(self::DAYS_BETWEEN_TRACKING_REQUESTS, Zend_Date::DAY)->isEarlier(new Zend_Date());
}
示例15: validateAge
public function validateAge($value)
{
$parts = @explode('-', $value);
// Error if not filled out
if (count($parts) < 3 || count(array_filter($parts)) < 3) {
//$this->addError('Please fill in your birthday.');
return false;
}
$value = mktime(0, 0, 0, $parts[1], $parts[2], $parts[0]);
// Error if too low
$date = new Zend_Date($value);
$date->add((int) $this->min_age, Zend_Date::YEAR);
if ($date->compare(new Zend_Date()) > 0) {
//$this->addError('You are not old enough.');
return false;
}
return true;
}