获取一天是一年中的第几天

/**
     * 获取今天是一年中的第几天
     * @param string $date
     * @return string
     */
    public static function getDays($date = '') {
        $now_date = $date !== '' ? $date : date('Y-m-d');
        $first_date = date('Y',strtotime($now_date)).'-01-01';
        $diff_times = strtotime($now_date) - strtotime($first_date);
        return MathUtil::div($diff_times , 86400,0) + 1;
    }

Tips: 1 号是第一天 ,2 号是第二天。

posted @ 2019-08-01 11:06  TBHacker  阅读(611)  评论(0编辑  收藏  举报