/** * 获取本周第一天/最后一天的时间戳 * @param string $type * @return integer */ public function get_week_time( $type = 'first' ) { /* 获取本周第一天/最后一天的时间戳 */ $year = date( "Y" ); $month = date( "m" ); $day = date( 'w' ); $nowMonthDay = date( "t" ); if ( $type == 'first' ) { $firstday = date( 'd' ) - $day; if ( substr( $firstday, 0, 1 ) == "-" ) { $firstMonth = $month - 1; $lastMonthDay = date( "t", $firstMonth ); $firstday = $lastMonthDay - substr( $firstday, 1 ); $time_1 = strtotime( $year . "-" . $firstMonth . "-" . $firstday ); } else { $time_1 = strtotime( $year . "-" . $month . "-" . $firstday ); } return $time_1; } else { $lastday = date( 'd' ) + (7 - $day); if ( $lastday > $nowMonthDay ) { $lastday = $lastday - $nowMonthDay; $lastMonth = $month + 1; $time_2 = strtotime( $year . "-" . $lastMonth . "-" . $lastday ); } else { $time_2 = strtotime( $year . "-" . $month . "-" . $lastday ); } return $time_2; } } /** * 获取本月第一天/最后一天的时间戳 * @param string $type * @return integer */ public function get_month_time( $type = 'first' ) { /* 获取本月第一天/最后一天的时间戳 */ $year = date( "Y" ); $month = date( "m" ); $allday = date( "t" ); if ( $type == 'first' ) { $start_time = strtotime( $year . "-" . $month . "-1" ); return $start_time; } else { $end_time = strtotime( $year . "-" . $month . "-" . $allday ); return $end_time; } }
如对本文有疑问, 点击进行留言回复!!
[ACTF2020 新生赛]Include 1【文件包含】【读取代码】
算法题解 - 牛客编程巅峰赛S1第6场 - 黄金&钻石&王者组
推荐一个程序员必备网站之一:Dev Hints ,非常实用!
网友评论