Home >Backend Development >PHP Tutorial >php get the first and last day of each month instance

php get the first and last day of each month instance

WBOY
WBOYOriginal
2016-07-25 09:13:15991browse

Example, php gets the first and last day of each month. PHP date function date usage.

  1. function getthemonth($date)
  2. {
  3. $firstday = date('y-m-01', strtotime($date));
  4. $lastday = date('y-m-d', strtotime("$firstday +1 month -1 day"));
  5. return array($firstday,$lastday);
  6. }
  7. $today = date("y-m-d");
  8. $day=getthemonth($today);
  9. ?>
Copy code


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn