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

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

PHP中文网
Release: 2016-05-25 17:03:56
Original
2843 people have browsed it

[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;));
    }
}
Copy after login

                   

                   

Related labels:
php
source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template