Sample code
| The code is as follows |
|
|
Gets the first and last day of the month on which the specified date is located
function Getthemonth ($date) {
$firstday = Date ("y-m-01", Strtotime ($date));
$lastday = Date ("y-m-d", Strtotime ("$firstday +1 month-1 Day"));
Return Array ($firstday, $lastday);
} |
Sample code
PHP gets the first and last day of the week of the specified date
| The code is as follows |
|
|
function GetDays ($day) {
$lastday =date (' y-m-d ', Strtotime ("$day Sunday"));
$firstday =date (' y-m-d ', Strtotime ("$lastday-6 Days"));
Return Array ($firstday, $lastday);
}
Print_r (getdays (' 2012-06-2 ')); |
Sample code
| code as follows |
|
|
$date = date to process
* $step 0 = this month, positive and negative indicates the month before and after the month date
* $date = The month to process
* Enter description ...
*/
Function assigntabmonth ($date, $step) {
$date = date ("y-m-d", Strtotime ($step. "Months", Strtotime ($date) )//The date of the processing (the date before and after the month)
$u _date = Strtotime ($date);
$days =date ("T", $u _date); Number of days to get the result month
//Date of the first day of the month
$first _date=date ("Y-m", $u _date). ' -01 ';
for ($i =0; $i < $days; $i + +) {
$for _day=date ("y-m-d", Strtotime ($first _date) + ($i *3600*24));
}
return $first _date. ' to '. $for _day; |