当前位置: 首页>>代码示例>>PHP>>正文


PHP date_sub函数代码示例

本文整理汇总了PHP中date_sub函数的典型用法代码示例。如果您正苦于以下问题:PHP date_sub函数的具体用法?PHP date_sub怎么用?PHP date_sub使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了date_sub函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test_date_sub

function test_date_sub()
{
    $datetime = date_create("2010-08-16");
    $interval = date_interval_create_from_date_string("2 weeks");
    $dt2 = date_sub($datetime, $interval);
    return date_format($dt2, "Y-m-d");
}
开发者ID:badlamer,项目名称:hhvm,代码行数:7,代码来源:timelib_dependent.php

示例2: jireRest

 public function jireRest(Request $request)
 {
     try {
         //$jira_rest = \Drupal::service('jira_rest.jira_rest_service');
         $container = \Drupal::getContainer();
         $jira = JiraRestController::create($container);
         $author_name = $jira->config('jira_rest.settings')->get('jira_rest.username');
         $interval = "-2d";
         $res = $jira->jira_rest_searchissue("updated >= " . $interval . " AND assignee in (" . $author_name . ")");
     } catch (JiraRestException $e) {
         $responce['messages'][] = $e->getMessage();
     }
     $responce = array();
     $interval = abs(intval($interval));
     $sub_days = "{$interval} days";
     $date = date_create();
     $toDate = date_format($date, 'Y-m-d');
     date_sub($date, date_interval_create_from_date_string($sub_days));
     $fromDate = date_format($date, 'Y-m-d');
     foreach ($res->issues as $issue) {
         $worklog = $jira->jira_rest_get_worklog($issue->key);
         foreach ($worklog->worklogs as $entry) {
             $shortDate = substr($entry->started, 0, 10);
             # keep a worklog entry on $key item,
             # iff within the search time period
             if ($entry->author->name == $author_name && $shortDate >= $fromDate && $shortDate <= $toDate) {
                 $responce[$issue->key] += $entry->timeSpentSeconds;
             }
         }
     }
 }
开发者ID:lokeoke,项目名称:d8intranet,代码行数:31,代码来源:JiraRestWorkLogController.php

示例3: page

 /**
  * Loads a page in the registration process
  * Page 1 = Login information
  * Page 2 = Profile information
  * Page 3 = Profile information
  * Page 4 = Confirm information
  * @param $page int requested page number
  */
 public function page($page)
 {
     if (!isset($page)) {
         $page = 0;
     }
     if ($page == 1) {
         $this->view->title = 'Login information';
         $this->view->render('register/authenticationInfo');
     } elseif ($page == 2) {
         $this->view->title = 'Profile information';
         $this->view->genders = $this->model->getGenders();
         $this->view->maxDate = date_sub(date_create(), date_interval_create_from_date_string('13 years'));
         $this->view->minDate = date_sub(date_create(), date_interval_create_from_date_string('101 years'));
         $this->view->render('register/userInfo');
     } elseif ($page == 3) {
         $this->view->title = 'Profile information';
         $this->view->countries = $this->model->getCountries();
         $this->view->render('register/addressInfo');
     } elseif ($page == 4) {
         $this->view->title = 'Confirm information';
         if (isset($this->newUser['gender_id'])) {
             $this->view->gender = $this->model->getGender($this->newUser['gender_id']);
         }
         if (isset($this->newUser['country'])) {
             $this->view->country = $this->model->getCountry($this->newUser['country']);
         }
         $this->view->canSubmit = $this->validate();
         $this->view->render('register/regConfirm');
     } else {
         $this->view->render('register/index');
     }
 }
开发者ID:skiracerdude,项目名称:eCommerceCaseStudy,代码行数:40,代码来源:register.php

示例4: createAction

 /**
  * Creates a new Events entity.
  *
  */
 public function createAction(Request $request)
 {
     $entity = new Events();
     $form = $this->createCreateForm($entity);
     $form->handleRequest($request);
     // On récupère la date de début et de fin d'évènement afin de les comparer
     $startEvent = $form->getViewData()->getStart();
     $startEvent_string = strftime("%A %#d %B %Y à %k:%M", $startEvent->getTimestamp());
     $endEvent = $form->getViewData()->getEnd();
     if ($form->isValid()) {
         // On détermine la différence entre les heures et les minutes
         $diffTime_min = date_diff($startEvent, $endEvent)->i;
         $diffTime_hour = date_diff($startEvent, $endEvent)->h;
         // Si la durée de l'event est inferieur à une heure, alors, on le met à une heure automatiquement
         if ($diffTime_min <= 59 && $diffTime_hour == 0) {
             date_sub($endEvent, date_interval_create_from_date_string($diffTime_min . 'min'));
             $entity->setEnd($endEvent->modify('+1 hours'));
         }
         $em = $this->getDoctrine()->getManager();
         $user = $this->container->get('security.token_storage')->getToken()->getUser();
         // On se protège de la faille XSS
         $entity->setTitre(htmlspecialchars($form->getViewData()->getTitre()));
         $entity->setResume(htmlspecialchars($form->getViewData()->getResume()));
         $entity->setDateAjout(new \DateTime());
         $entity->setIdUser($user);
         $this->colorEvent($entity);
         $em->persist($entity);
         $em->flush();
         return $this->redirect($this->generateUrl('agenda_homepage'));
     }
     return $this->render('AgendaBundle:Events:new.html.twig', array('entity' => $entity, 'form' => $form->createView(), 'startEvent' => $startEvent_string));
 }
开发者ID:WildCodeSchool,项目名称:partnet,代码行数:36,代码来源:EventsController.php

示例5: indexAction

 public function indexAction(Request $request, SessionInterface $session)
 {
     if (Util::checkUserIsLoggedIn()) {
         $loggedInUserId = $session->get('user/id');
         $clientId = $session->get('client/id');
         $clientSettings = $session->get('client/settings');
     } else {
         $loggedInUserId = null;
         $clientId = $this->getRepository(UbirimiClient::class)->getClientIdAnonymous();
         $clientSettings = $this->getRepository(UbirimiClient::class)->getSettings($clientId);
     }
     $projectId = $request->get('id');
     $project = $this->getRepository(YongoProject::class)->getById($projectId);
     if ($project['client_id'] != $clientId) {
         return new RedirectResponse('/general-settings/bad-link-access-denied');
     }
     $currentDate = Util::getServerCurrentDateTime();
     $dateFrom = date_create(Util::getServerCurrentDateTime());
     $dateTo = date_format(date_create(Util::getServerCurrentDateTime()), 'Y-m-d');
     date_sub($dateFrom, date_interval_create_from_date_string('1 months'));
     $dateFrom = date_format($dateFrom, 'Y-m-d');
     $issueQueryParameters = array('project' => array($projectId), 'resolution' => array(-2));
     $issues = $this->getRepository(Issue::class)->getByParameters($issueQueryParameters, $loggedInUserId, null, $loggedInUserId);
     $hasGlobalAdministrationPermission = $this->getRepository(UbirimiUser::class)->hasGlobalPermission($clientId, $loggedInUserId, GlobalPermission::GLOBAL_PERMISSION_YONGO_ADMINISTRATORS);
     $hasGlobalSystemAdministrationPermission = $this->getRepository(UbirimiUser::class)->hasGlobalPermission($clientId, $loggedInUserId, GlobalPermission::GLOBAL_PERMISSION_YONGO_SYSTEM_ADMINISTRATORS);
     $hasAdministerProjectsPermission = $this->getRepository(UbirimiClient::class)->getProjectsByPermission($clientId, $loggedInUserId, Permission::PERM_ADMINISTER_PROJECTS);
     $hasAdministerProject = $hasGlobalSystemAdministrationPermission || $hasGlobalAdministrationPermission || $hasAdministerProjectsPermission;
     $sectionPageTitle = $clientSettings['title_name'] . ' / ' . SystemProduct::SYS_PRODUCT_YONGO_NAME . ' / ' . $project['name'] . ' / Reports';
     $menuSelectedCategory = 'project';
     return $this->render(__DIR__ . '/../../Resources/views/project/ViewReportsSummary.php', get_defined_vars());
 }
开发者ID:spiasecki,项目名称:ubirimi,代码行数:31,代码来源:ViewReportsSummaryController.php

示例6: getDates

function getDates($dayofmonth, $months = 0)
{
    $dayofmonth = zeropad($dayofmonth);
    $year = date('Y');
    $month = date('m');
    if (date('d') > $dayofmonth) {
        // Billing day is past, so it is next month
        $date_end = date_create($year . '-' . $month . '-' . $dayofmonth);
        $date_start = date_create($year . '-' . $month . '-' . $dayofmonth);
        date_add($date_end, date_interval_create_from_date_string('1 month'));
    } else {
        // Billing day will happen this month, therefore started last month
        $date_end = date_create($year . '-' . $month . '-' . $dayofmonth);
        $date_start = date_create($year . '-' . $month . '-' . $dayofmonth);
        date_sub($date_start, date_interval_create_from_date_string('1 month'));
    }
    if ($months > 0) {
        date_sub($date_start, date_interval_create_from_date_string($months . ' month'));
        date_sub($date_end, date_interval_create_from_date_string($months . ' month'));
    }
    // date_sub($date_start, date_interval_create_from_date_string('1 month'));
    date_sub($date_end, date_interval_create_from_date_string('1 day'));
    $date_from = date_format($date_start, 'Ymd') . '000000';
    $date_to = date_format($date_end, 'Ymd') . '235959';
    date_sub($date_start, date_interval_create_from_date_string('1 month'));
    date_sub($date_end, date_interval_create_from_date_string('1 month'));
    $last_from = date_format($date_start, 'Ymd') . '000000';
    $last_to = date_format($date_end, 'Ymd') . '235959';
    $return = array();
    $return['0'] = $date_from;
    $return['1'] = $date_to;
    $return['2'] = $last_from;
    $return['3'] = $last_to;
    return $return;
}
开发者ID:Tatermen,项目名称:librenms,代码行数:35,代码来源:billing.php

示例7: sendmailAction

 public function sendmailAction()
 {
     //Print header for log
     echo "********************\n";
     echo "sendmailAction START\n";
     echo date('Y-m-d H:i:s e') . "\n";
     echo "********************\n";
     //Initialize variables
     $sm = $this->getServiceLocator();
     $books = new Books($sm);
     $users = new Users($sm);
     $mailler = new Mailler($sm);
     //Get new books from last week
     $lastDate = date("o-m-d", date_sub(new DateTime(), date_interval_create_from_date_string("7 days"))->getTimestamp());
     $bookList = $books->listBooks(array("sql" => "date >= '{$lastDate}'"))->toArray();
     //Print list of new books
     echo "LIST OF BOOKS:\n";
     foreach ($bookList as $book) {
         echo "\t" . $book['title'] . "\n";
     }
     //Get list of subscribed users
     $userList = $users->listUsers("weeklynews = 1")->toArray();
     //Print list of subscribed users
     echo "LIST OF EMAILS:\n";
     foreach ($userList as $user) {
         echo "\t" . $user['email'] . "\n";
     }
     //Send mails if there is at least one new book
     if (count($bookList) > 0) {
         $mailler->newsletterEmail($userList, $bookList, date("d/m/o"));
     }
     die;
 }
开发者ID:amnarciso,项目名称:bookcloud,代码行数:33,代码来源:ConsoleController.php

示例8: beforeFilter

 public function beforeFilter()
 {
     //        if($this->Auth->user('role') != 'admin'){
     //            $this->Session->setFlash('No esta autorizado a consultar esa pagina');
     //            $this->redirect(array('controller' => 'application', 'action' => 'detail','addon.simplylock.theme.example'));
     //            die();
     //        }
     //algunas cosas de aca se tienen que validar en el metodo como es el caso del upload cuando este
     $this->Auth->allow('logout');
     //        if ($this->Session->check('Config.language')) {
     //            Configure::write('Config.language', $this->Session->read('Config.language'));
     //        }
     //        else{
     //            Configure::write('Config.language', 'esp');
     //        }
     $this->set('logged_in', $this->Auth->loggedIn());
     $this->set('userAutenticated', $this->Auth->user());
     $this->set('isadmin', $this->Auth->user()['role'] == 'admin' ? 1 : 0);
     //data for menu
     //put data en la pagina
     $config = $this->Configuration->find('first', array('conditions' => array('Configuration.id' => 1)));
     $dayToNew = $config['Configuration']['days_to_new'];
     $date = date_create('now');
     date_sub($date, date_interval_create_from_date_string($dayToNew . ' days'));
     $settings = array('conditions' => array('Application.created >= "' . $date->format('Y-m-d H:i:s') . '"'));
     $cantNew = $this->Application->find('count', $settings);
     $settings1 = array('conditions' => array('Application.recommended ' => 1));
     $cantRecomended = $this->Application->find('count', $settings1);
     $settings1 = array('conditions' => array('Application.verificate ' => 1));
     $cantverificate = $this->Application->find('count', $settings1);
     $this->set('cantnews', $cantNew);
     $this->set('recommended', $cantRecomended);
     $this->set('verificate', $cantverificate);
 }
开发者ID:sergelg90,项目名称:sasweb,代码行数:34,代码来源:AppController.php

示例9: getAndIndexNotifications

 /**
  * Return an array of raw html notifications, delay in [s]
  */
 private function getAndIndexNotifications($daysBack = 14, $delay = 0.5)
 {
     $date = new DateTime();
     // DateTime::createFromFormat('d-m-Y', $enddate);
     date_sub($date, date_interval_create_from_date_string($daysBack . ' days'));
     $p = 0;
     $alreadyStoredPages = 0;
     // remove database entries older than given date
     $this->deleteEntriesInDatabase($date);
     $Scraper = new P2000Scraper("http://www.p2000-online.net/alleregiosf.html");
     while ($this->entriesInDatabase($date) == 0) {
         //&& $alreadyStoredPages<5) {
         $Scraper->scrapePage();
         $now = round(microtime(true) * 1000);
         $alreadyStored = $this->indexNotifications($Scraper->getRawNotifications());
         $elapsed = round(microtime(true) * 1000) - $now;
         if ($elapsed < $delay * 1000.0) {
             // ensure proper delay between requests
             usleep(($delay - $elapsed / 1000.0) * 1000000);
         }
         $end = round(microtime(true) * 1000) - $now;
         if ($alreadyStored == 15) {
             $alreadyStoredPages++;
         }
         $Scraper->clearRawNotifications();
         $Scraper->loadNextPage();
         $p++;
         //echo "Scraped " . $p . " pages - Time elapsed: " . $elapsed . "[ms] <br/>"; // for webpage
         fwrite(STDOUT, "\n\tScraped " . $p . " pages - Time elapsed: " . $end . "[ms]\n");
         // for CLI
         $amount = $this->entriesInDatabase($date);
         fwrite(STDOUT, $amount . " pages indexed of date: " . $date->format('d-m-Y') . "\n");
         //->format('d-m-Y')."\n");
     }
 }
开发者ID:Bram9205,项目名称:WebInfo,代码行数:38,代码来源:Main.php

示例10: show

    public function show()
    {
        //nuvarande månad
        $d = "20" . $this->year . "-" . $this->monthNr . "-01";
        $date = date_create($d);
        //nästa månad
        $nextdate = date_add($date, date_interval_create_from_date_string('1 month'));
        $next = "y=" . date_format($nextdate, "y") . "&amp;m=" . date_format($nextdate, "n");
        //föregående månad
        $prevdate = date_sub($date, date_interval_create_from_date_string('2 months'));
        $prev = "y=" . date_format($prevdate, "y") . "&amp;m=" . date_format($prevdate, "n");
        $html = <<<EOT
     <header>
     <a class="left navsquare" href="?p=calendar&amp;{$prev}">&#10094;</a>
     <a class="right navsquare" href="?p=calendar&amp;{$next}">&#10095;</a>
     <h2 class="strokeme">{$this->month} 20{$this->year}</h2>
     <img class="header" src="img/calendar/{$this->getMonthImage()}" 
     alt="image of the month"></header>
     

    <section>\t
     {$this->calendarTable()}
     {$this->showHollidays()}
    </section>
EOT;
        return $html;
    }
开发者ID:bthurvi,项目名称:oophp,代码行数:27,代码来源:CCalendar.php

示例11: getDates

function getDates($dayofmonth, $months = 0)
{
    $dayofmonth = zeropad($dayofmonth);
    $year = date('Y');
    $month = date('m');
    if (date('d') >= $dayofmonth) {
        $date_end = date_create($year . '-' . $month . '-' . $dayofmonth);
        $date_start = date_create($year . '-' . $month . '-' . $dayofmonth);
        date_add($date_end, date_interval_create_from_date_string('1 月'));
    } else {
        // Billing day will happen this month, therefore started last month
        $date_end = date_create($year . '-' . $month . '-' . $dayofmonth);
        $date_start = date_create($year . '-' . $month . '-' . $dayofmonth);
        date_sub($date_start, date_interval_create_from_date_string('1 月'));
    }
    if ($months > 0) {
        date_sub($date_start, date_interval_create_from_date_string($months . ' 月'));
        date_sub($date_end, date_interval_create_from_date_string($months . ' 月'));
    }
    #  date_sub($date_start, date_interval_create_from_date_string('1 月'));
    date_sub($date_end, date_interval_create_from_date_string('1 天'));
    $date_from = date_format($date_start, 'Ymd') . "000000";
    $date_to = date_format($date_end, 'Ymd') . "235959";
    date_sub($date_start, date_interval_create_from_date_string('1 月'));
    date_sub($date_end, date_interval_create_from_date_string('1 月'));
    $last_from = date_format($date_start, 'Ymd') . "000000";
    $last_to = date_format($date_end, 'Ymd') . "235959";
    $return['0'] = $date_from;
    $return['1'] = $date_to;
    $return['2'] = $last_from;
    $return['3'] = $last_to;
    return $return;
}
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:33,代码来源:billing.inc.php

示例12: indexAction

 public function indexAction($actif, $page, $maxPerPage)
 {
     $em = $this->getDoctrine()->getManager();
     $layout = $this->getLayout($em);
     // $maxPerPage = 1;
     // suppression des offres datant de plus d'un an
     $dateOld = new \Datetime();
     date_sub($dateOld, date_interval_create_from_date_string('1 year'));
     $query = $this->getDoctrine()->getRepository('AMiEOffreEmploiBundle:OffreEmploi')->findOld($dateOld);
     $offresOld = $query->getResult();
     for ($i = 0; $i < sizeof($offresOld); $i++) {
         $em->remove($offresOld[$i]);
         $em->flush();
     }
     switch ($actif) {
         case 'actif':
             $offres = $em->getRepository('AMiEOffreEmploiBundle:OffreEmploi')->findBy(array('actif' => 'A'), array('updatedDate' => 'DESC'));
             $pagerfanta = new Pagerfanta(new ArrayAdapter($offres));
             $pagerfanta->setMaxPerPage($maxPerPage);
             try {
                 $pagerfanta->setCurrentPage($page);
             } catch (NotValidCurrentPageException $e) {
                 throw new NotFoundHttpException();
             }
             break;
         case 'inactif':
             $offres = $em->getRepository('AMiEOffreEmploiBundle:OffreEmploi')->findBy(array('actif' => 'F'), array('updatedDate' => 'DESC'));
             $pagerfanta = new Pagerfanta(new ArrayAdapter($offres));
             $pagerfanta->setMaxPerPage($maxPerPage);
             try {
                 $pagerfanta->setCurrentPage($page);
             } catch (NotValidCurrentPageException $e) {
                 throw new NotFoundHttpException();
             }
             break;
         case 'tous':
             $offres = $em->getRepository('AMiEOffreEmploiBundle:OffreEmploi')->findBy(array(), array('updatedDate' => 'DESC'));
             $pagerfanta = new Pagerfanta(new ArrayAdapter($offres));
             $pagerfanta->setMaxPerPage($maxPerPage);
             try {
                 $pagerfanta->setCurrentPage($page);
             } catch (NotValidCurrentPageException $e) {
                 throw new NotFoundHttpException();
             }
             break;
         default:
             $offres = $em->getRepository('AMiEOffreEmploiBundle:OffreEmploi')->findBy(array('actif' => 'A'), array('updatedDate' => 'DESC'));
             $pagerfanta = new Pagerfanta(new ArrayAdapter($offres));
             $pagerfanta->setMaxPerPage($maxPerPage);
             try {
                 $pagerfanta->setCurrentPage($page);
             } catch (NotValidCurrentPageException $e) {
                 throw new NotFoundHttpException();
             }
             $actif = 'actif';
             break;
     }
     return $this->render('AMiEOffreEmploiBundle:Offres:index.html.twig', array('layout' => $layout, 'actif' => $actif, 'offres' => $pagerfanta));
 }
开发者ID:mikaSez,项目名称:AMiE,代码行数:59,代码来源:OffresController.php

示例13: getTimeRange

function getTimeRange($deltaTime)
{
    global $toDate, $fromDate;
    $toDate = date_create(date("Y-m-d"));
    $fromDate = date_create(date("Y-m-d"));
    date_sub($fromDate, date_interval_create_from_date_string($deltaTime));
    $fromDate = date_format($fromDate, "Y-m-d");
    $toDate = date_format($toDate, "Y-m-d");
}
开发者ID:panbognot,项目名称:stana,代码行数:9,代码来源:genTradeRecom.php

示例14: getHomeTopNews

 function getHomeTopNews($catId = 0)
 {
     global $_CORELANG, $objDatabase;
     $catId = intval($catId);
     $i = 0;
     $this->_objTemplate->setTemplate($this->_pageContent, true, true);
     if ($this->_objTemplate->blockExists('newsrow')) {
         $this->_objTemplate->setCurrentBlock('newsrow');
     } else {
         return null;
     }
     $newsLimit = intval($this->arrSettings['news_top_limit']);
     if ($newsLimit > 50) {
         //limit to a maximum of 50 news
         $newsLimit = 50;
     }
     if ($newsLimit < 1) {
         //do not get any news if 0 was specified as the limit.
         $objResult = false;
     } else {
         //fetch news
         $objResult = $objDatabase->SelectLimit("\n                SELECT DISTINCT(tblN.id) AS id,\n                       tblN.`date`, \n                       tblN.teaser_image_path,\n                       tblN.teaser_image_thumbnail_path,\n                       tblN.redirect,\n                       tblN.publisher,\n                       tblN.publisher_id,\n                       tblN.author,\n                       tblN.author_id,\n                       tblL.title AS title, \n                       tblL.teaser_text\n                  FROM " . DBPREFIX . "module_news AS tblN\n            INNER JOIN " . DBPREFIX . "module_news_locale AS tblL ON tblL.news_id=tblN.id\n            INNER JOIN " . DBPREFIX . "module_news_rel_categories AS tblC ON tblC.news_id=tblL.news_id\n                  WHERE tblN.status=1" . ($catId > 0 ? " AND tblC.category_id={$catId}" : '') . "\n                   AND tblN.teaser_only='0'\n                   AND tblL.lang_id=" . FRONTEND_LANG_ID . "\n                   AND (startdate<='" . date('Y-m-d H:i:s') . "' OR startdate='0000-00-00 00:00:00')\n                   AND (enddate>='" . date('Y-m-d H:i:s') . "' OR enddate='0000-00-00 00:00:00')" . ($this->arrSettings['news_message_protection'] == '1' && !\Permission::hasAllAccess() ? ($objFWUser = \FWUser::getFWUserObject()) && $objFWUser->objUser->login() ? " AND (frontend_access_id IN (" . implode(',', array_merge(array(0), $objFWUser->objUser->getDynamicPermissionIds())) . ") OR userid=" . $objFWUser->objUser->getId() . ") " : " AND frontend_access_id=0 " : '') . "ORDER BY\n                       (SELECT COUNT(*) FROM " . DBPREFIX . "module_news_stats_view WHERE news_id=tblN.id AND time>'" . date_format(date_sub(date_create('now'), date_interval_create_from_date_string(intval($this->arrSettings['news_top_days']) . ' day')), 'Y-m-d H:i:s') . "') DESC", $newsLimit);
     }
     if ($objResult !== false && $objResult->RecordCount()) {
         while (!$objResult->EOF) {
             $newsid = $objResult->fields['id'];
             $newstitle = $objResult->fields['title'];
             $author = \FWUser::getParsedUserTitle($objResult->fields['author_id'], $objResult->fields['author']);
             $publisher = \FWUser::getParsedUserTitle($objResult->fields['publisher_id'], $objResult->fields['publisher']);
             $newsCategories = $this->getCategoriesByNewsId($newsid);
             $newsUrl = empty($objResult->fields['redirect']) ? \Cx\Core\Routing\Url::fromModuleAndCmd('News', $this->findCmdById('details', self::sortCategoryIdByPriorityId(array_keys($newsCategories), array($catId))), FRONTEND_LANG_ID, array('newsid' => $newsid)) : $objResult->fields['redirect'];
             $htmlLink = self::parseLink($newsUrl, $newstitle, contrexx_raw2xhtml($newstitle));
             list($image, $htmlLinkImage, $imageSource) = self::parseImageThumbnail($objResult->fields['teaser_image_path'], $objResult->fields['teaser_image_thumbnail_path'], $newstitle, $newsUrl);
             $this->_objTemplate->setVariable(array('NEWS_ID' => $newsid, 'NEWS_CSS' => 'row' . ($i % 2 + 1), 'NEWS_LONG_DATE' => date(ASCMS_DATE_FORMAT, $objResult->fields['date']), 'NEWS_DATE' => date(ASCMS_DATE_FORMAT_DATE, $objResult->fields['date']), 'NEWS_TIME' => date(ASCMS_DATE_FORMAT_TIME, $objResult->fields['date']), 'NEWS_TITLE' => contrexx_raw2xhtml($newstitle), 'NEWS_TEASER' => nl2br($objResult->fields['teaser_text']), 'NEWS_LINK' => $htmlLink, 'NEWS_LINK_URL' => contrexx_raw2xhtml($newsUrl), 'NEWS_AUTHOR' => contrexx_raw2xhtml($author), 'NEWS_PUBLISHER' => contrexx_raw2xhtml($publisher)));
             if (!empty($image)) {
                 $this->_objTemplate->setVariable(array('NEWS_IMAGE' => $image, 'NEWS_IMAGE_SRC' => contrexx_raw2xhtml($imageSource), 'NEWS_IMAGE_ALT' => contrexx_raw2xhtml($newstitle), 'NEWS_IMAGE_LINK' => $htmlLinkImage));
                 if ($this->_objTemplate->blockExists('news_image')) {
                     $this->_objTemplate->parse('news_image');
                 }
             } else {
                 if ($this->_objTemplate->blockExists('news_image')) {
                     $this->_objTemplate->hideBlock('news_image');
                 }
             }
             self::parseImageBlock($this->_objTemplate, $objResult->fields['teaser_image_thumbnail_path'], $newstitle, $newsUrl, 'image_thumbnail');
             self::parseImageBlock($this->_objTemplate, $objResult->fields['teaser_image_path'], $newstitle, $newsUrl, 'image_detail');
             $this->_objTemplate->parseCurrentBlock();
             $i++;
             $objResult->MoveNext();
         }
     } else {
         $this->_objTemplate->hideBlock('newsrow');
     }
     $this->_objTemplate->setVariable("TXT_MORE_NEWS", $_CORELANG['TXT_MORE_NEWS']);
     return $this->_objTemplate->get();
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:56,代码来源:NewsTop.class.php

示例15: date_subtract

 function date_subtract($no_of_days, $start_date = NULL, $format = "Y-m-d")
 {
     if (isset($start_date)) {
         $date = $start_date;
     } else {
         $date = date_create(date("Y-m-d"));
     }
     date_sub($date, date_interval_create_from_date_string($no_of_days . ' days'));
     return date_format($date, $format);
 }
开发者ID:hfugen112678,项目名称:webforms,代码行数:10,代码来源:my_datetime_helper.php


注:本文中的date_sub函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。