A recent project on the timeline, giving a start time and an end time, you need to list the dates in this time period and also determine how many weeks. After research, come up with the following methods, and we share, to facilitate the need for friends.
First, the effect of this demand map:
The following is a specific code fragment:
* * Parameters are start timestamp, end timestamp
/function Timelist ($beginTimeStamp, $endTimeStamp) {
if!is_numeric ($ Begintimestamp)!is_numeric ($endTimeStamp) ($endTimeStamp <= $beginTimeStamp)) return "";
$tmp =array ();
for ($i = $beginTimeStamp; $i <= $endTimeStamp; $i + = (24*3600)) {
$tmp ["Timestamplist"][]= $i;
$tmp ["Daylist"][]=date ("Y-year m-month D-Day", $i);
$tmp ["DayWeek"][]=getweek ($i);
}
return $tmp;
}
function Getweek ($timestamp) {
$timestamp =date ("W", $timestamp);
$str = "";//http://www.alixixi.com/php-function/969.html
switch ($timestamp) {case
"0":
$str. = "Sunday";
break;
Case "1":
$str. = "Monday";
break;
Case "2":
$str. = "Tuesday";
break;
Case "3":
$str. = "Wednesday";
break;
Case "4":
$str. = "Thursday";
break;
Case "5":
$str. = "Friday";
break;
Case "6":
$str. = "Saturday";
break;
return $str;
}
Articles that you may be interested in
- PHP gets the method for each month over a period of time, returning an array of these months
- How PHP Gets the start time stamp and end time stamp for today, yesterday, last week, month
- PHP gets a list of dates 30 days before the current date
- Why the programmer estimates the time and the project actually completes the time always has the error
- PHP Gets the list of all the pictures in the content and outputs the method
- PHP implementation to instantly output the results to the browser
- PHP Gets the Ganzhi annals, Zodiac and constellation information based on a date or time stamp
- PHP extracts the birthday date in the ID number and the function to verify that it is a minor