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


PHP JevDate::add方法代码示例

本文整理汇总了PHP中JevDate::add方法的典型用法代码示例。如果您正苦于以下问题:PHP JevDate::add方法的具体用法?PHP JevDate::add怎么用?PHP JevDate::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JevDate的用法示例。


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

示例1: Defaultgetstartenddates

function Defaultgetstartenddates($view)
{
    $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
    $startdate = JRequest::getString("startdate", "");
    $enddate = JRequest::getString("enddate", "");
    if ($startdate == "") {
        if ($params->get("relative", "rel") == "abs") {
            $startdate = $params->get("absstart", "");
            list($startyear, $startmonth, $startday) = explode("-", $startdate);
        } else {
            if ($params->get("relative", "rel") == "strtotime") {
                $value = $params->get("strstart", "");
                $value = new JevDate(JevDate::strtotime($value));
                $startdate = $value->toFormat("%Y-%m-%d");
            } else {
                $value = $params->get("relstart", "");
                $value = str_replace(",", " ", $value);
                $value = str_replace("y", "year", $value);
                $value = str_replace("d", "day", $value);
                $value = str_replace("w", "week", $value);
                $value = str_replace("m", "month", $value);
                $value = new JevDate($value);
                $startdate = $value->toFormat("%Y-%m-%d");
            }
        }
    }
    if ($enddate == "") {
        if ($params->get("relative", "rel") == "abs") {
            $enddate = $params->get("absend", "");
        } else {
            if ($params->get("relative", "rel") == "strtotime") {
                $value = $params->get("strend", "");
                $value = new JevDate(JevDate::strtotime($value));
                $enddate = $value->toFormat("%Y-%m-%d");
            } else {
                $value = $params->get("relend", "");
                $value = str_replace(",", " ", $value);
                $value = str_replace("y", "year", $value);
                $value = str_replace("d", "day", $value);
                $value = str_replace("w", "week", $value);
                $value = str_replace("m", "month", $value);
                $value = new JevDate($value);
                $enddate = $value->toFormat("%Y-%m-%d");
            }
        }
    }
    if ($enddate < $startdate) {
        // default to 1 year when input dates are not valid!
        $value = new JevDate($startdate);
        $value->add(new DateInterval('P1Y'));
        $enddate = $value->toFormat("%Y-%m-%d");
    }
    return array($startdate, $enddate);
}
开发者ID:madcsaba,项目名称:li-de,代码行数:54,代码来源:defaultgetstartenddates.php

示例2: Defaultgetstartenddates

function Defaultgetstartenddates($view)
{
    $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
    // fix to allow start/end date to be preserved during pagination IF filter module before/after dates are used
    $Itemid = JRequest::getInt("Itemid", 0);
    // This causes the filter module to reset
    $filters = jevFilterProcessing::getInstance(array());
    $activeFilterMenu = JFactory::getApplication()->getUserState('active_filter_menu ', $Itemid);
    if (intval(JRequest::getVar('filter_reset', 0)) || $activeFilterMenu > 0 && $activeFilterMenu != $Itemid) {
        JRequest::setVar('startdate', '');
        JRequest::setVar('enddate', '');
        JFactory::getApplication()->setUserState('range_enddate' . $Itemid, '');
        JFactory::getApplication()->setUserState('range_startdate' . $Itemid, '');
        JFactory::getApplication()->setUserState('active_filter_menu ', 0);
    }
    $startdate = JFactory::getApplication()->getUserStateFromRequest('range_startdate' . $Itemid, 'startdate', "");
    $enddate = JFactory::getApplication()->getUserStateFromRequest('range_enddate' . $Itemid, 'enddate', "");
    if ($startdate == "") {
        if ($params->get("relative", "rel") == "abs") {
            $startdate = $params->get("absstart", "");
            list($startyear, $startmonth, $startday) = explode("-", $startdate);
        } else {
            if ($params->get("relative", "rel") == "strtotime") {
                $value = $params->get("strstart", "");
                $value = new JevDate(JevDate::strtotime($value));
                $startdate = $value->toFormat("%Y-%m-%d");
            } else {
                $value = $params->get("relstart", "");
                $value = str_replace(",", " ", $value);
                $value = str_replace("y", "year", $value);
                $value = str_replace("d", "day", $value);
                $value = str_replace("w", "week", $value);
                $value = str_replace("m", "month", $value);
                $value = new JevDate($value);
                $startdate = $value->toFormat("%Y-%m-%d");
            }
        }
    }
    if ($enddate == "") {
        if ($params->get("relative", "rel") == "abs") {
            $enddate = $params->get("absend", "");
        } else {
            if ($params->get("relative", "rel") == "strtotime") {
                $value = $params->get("strend", "");
                $value = new JevDate(JevDate::strtotime($value));
                $enddate = $value->toFormat("%Y-%m-%d");
            } else {
                $value = $params->get("relend", "");
                $value = str_replace(",", " ", $value);
                $value = str_replace("y", "year", $value);
                $value = str_replace("d", "day", $value);
                $value = str_replace("w", "week", $value);
                $value = str_replace("m", "month", $value);
                $value = new JevDate($value);
                $enddate = $value->toFormat("%Y-%m-%d");
            }
        }
    }
    if ($enddate < $startdate) {
        // default to 1 year when input dates are not valid!
        $value = new JevDate($startdate);
        $value->add(new DateInterval('P1Y'));
        $enddate = $value->toFormat("%Y-%m-%d");
    }
    return array($startdate, $enddate);
}
开发者ID:hriggs,项目名称:cs-website,代码行数:66,代码来源:defaultgetstartenddates.php


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