zoukankan      html  css  js  c++  java
  • PHP日期相关类

    <?php
    class Date{
        /**
         * 获取某年某月的开始结束日期
         * @param int $year
         * @param int $month
         */
        public function getMonthStartEnd($year, $month){
            $firstday = date('Y-m-d', mktime(0, 0, 0, $month, 1,$year));
            $lastday = date('Y-m-d', mktime(0, 0, 0,$month+1,1,$year)-1);
            $return = array(
                    'start'=>$firstday,
                    'end'=>$lastday,
                    'stime'=>strtotime($firstday),
                    'etime'=>strtotime($lastday)
            );
            return $return;
        }
        
        /**
         * 获取某年某周的开始结束日期
         * @param int $year
         * @param int $week 1~52
         */
        public function getWeekStartEnd($year,$week){
            $weeks = date("W", mktime(0, 0, 0, 12, 28, $year));
            if ($week > $weeks || $week <= 0)
            {
                $week = 1;
            }
            if ($week < 10)
            {
                $week = '0' . $week;
            }
            $time['stime'] = strtotime($year . 'W' . $week);
            $time['etime'] = strtotime('+1 week -1 day', $time['stime']);
            $time['start'] = date('Y-m-d',$time['stime']);
            $time['end'] = date('Y-m-d',$time['etime']);
            return $time;
        }
    }
  • 相关阅读:
    WPF应用
    web窗体的运用
    关于计算器的封装
    典型用户、用户故事
    第五次作业
    第四次作业
    四则运算
    git 认识
    First article
    TODO
  • 原文地址:https://www.cnblogs.com/asunzhang/p/5983700.html
Copyright © 2011-2022 走看看