Home >php教程 >PHP源码 >PHP取得上周一、上周日,下周一

PHP取得上周一、上周日,下周一

PHP中文网
PHP中文网Original
2016-05-25 17:03:562875browse

[PHP]代码

<?php
/**
 * 取得下周一时的结算区间
 * @author ciogao@gmail.com
 */
class Project_View_Helper_TaskNotice
{

    /**
     * @return string
     */
    public function TaskNotice() {
        $nextMonday = $this->getNextMonday();
        $lastMonday = $this->getLastMonday();
        $lastSunday = $this->getLastSunday();
        $notice = &#39;下周一(&#39;. $nextMonday .&#39;)结算&#39;. $lastMonday .&#39;至&#39;. $lastSunday .&#39;的款项。(如遇节假日顺延)&#39;;
        return $notice;
    }

    /**
     * 取得下个周一
     * @internal param $time
     */
    private function getNextMonday()
    {
        return date(&#39;m月d日&#39;,strtotime(&#39;+1 week last monday&#39;));
    }

    /**
     * 取得上个周一
     * @return string
     */
    private function getLastMonday()
    {
        if (date(&#39;l&#39;,time()) == &#39;Monday&#39;) return date(&#39;m月d日&#39;,strtotime(&#39;last monday&#39;));
        
        return date(&#39;m月d日&#39;,strtotime(&#39;-1 week last monday&#39;));
    }

    /**
     * 取得上个周日
     * @return string
     */
    private function getLastSunday()
    {
        return date(&#39;m月d日&#39;,strtotime(&#39;last sunday&#39;));
    }
}

                   

                   

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn