1.get the first day and last day of the month.
echo Date (' y-m-01 ', Strtotime ('-1 month '));
echo "<br/>";
echo Date (' Y-m-t ', Strtotime ('-1 month '));
echo "<br/>";
2.get the first day of the month and the last day.
$BeginDate =date (' y-m-01 ', Strtotime (date ("y-m-d"));
Echo $BeginDate;
echo "<br/>";
echo Date (' y-m-d ', Strtotime ("$BeginDate +1 month-1 Day");
echo "<br/>";
3.get the day of the year, month, day, and days.
echo "Total this month:". Date ("T"). " Days ";
echo "Current year". Date (' Y ');
echo "Current Month". Date (' m ');
echo "Current Date". Date (' d ');
echo "<br/>";
4.use functions and arrays to get the first day of the month and the last day, more practical
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);
}
$today = Date ("y-m-d");
$day =getthemonth ($today);
echo "The first day of the month:". $day [0]. "Last day of the month:". $day [1];
echo "<br/>";
---------------------------------------------------------------------
PHP gets the first and last day of the week of the specified date
code as follows |
&NBSP; |
function GetDays ($day) { $lastday =date (' y-m-d ', Strtotime ("$day Sunday")); BR style= "margin:0px; padding:0px; " > $firstday =date (' y-m-d ', Strtotime ("$lastday-6 Days")); return Array ($firstday, $lastday); } Print_r (getdays (' 2012-06-2 ')); |
PHP Gets the days of the month and the first and last day of the month, the first day of the month, and the last day of the implementation method