我在网上找了半天,找到的都是不能用的,没辙就自己写了一个。
别跟我讨论是不是最优算法,多几个CPU时钟周期,死不了。
public static function getWeeks($format="second",$year=null){ if($year == null){ $year=date('Y'); } $second_of_day = 24*3600; $year_start = $year ."-01-01 00:00:00"; $year_end = $year ."-12-31 23:59:59"; $startday = strtotime($year_start); $day_of_week = date('N', $startday); $first_week_start=$startday; $first_week_end = $startday+(7-$day_of_week)*$second_of_day+$second_of_day-1; $week_array[0]=array($first_week_start,$first_week_end); $endday = strtotime($year_end); $day_of_week = date('N', $endday); $last_week_start=$endday-$day_of_week*$second_of_day+1; $last_week_end = $endday; $last_week=array($last_week_start,$last_week_end); $during = $last_week_start - $first_week_end; $during_total_week = intval($during/(7*$second_of_day)); for($i=0;$i<$during_total_week;$i++){ $week_array[$i+1]=array($first_week_end+(7*$i*$second_of_day)+1,$first_week_end+(($i+1)*$second_of_day*7)); } $week_array[$during_total_week+1]=$last_week; if($format !="second"){ foreach($week_array as $i => $week){ $week_array_of_date_format[$i]=array(date($format,$week[0]),date($format,$week[1])); } return $week_array_of_date_format; } return $week_array; }

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function