Blogger Information
Blog 175
fans 1
comment 0
visits 385840
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php 判断当前日期是否是每个月的第一天
dxp2tq的博客
Original
2176 people have browsed it
  1. <?php
  2. function getthemonth($date)
  3. {
  4. $firstday = date('Y-m-01', strtotime($date));
  5. $nowday = date('Y-m-d', strtotime($date));
  6. $lastday = date('Y-m-d', strtotime("$firstday +1 month -1 day"));
  7. return array($firstday,$nowday,$lastday);
  8. }
  9. $today = date("Y-m-d");
  10. $day=getthemonth($today);
  11. echo "当月的第一天: ".$day[0]." 当天日期: ".$day[1]." 当月的最后一天: ".$day[2];
  12. echo "<br/>";
  13. if($day[0] == $day[1]){
  14. echo '今天的日期是当月的第一天';
  15. }else{
  16. $num = explode('-',$day[1]);
  17. echo '今天的日期不是当月的第一天,而是第'.$num[2].'天';
  18. }
  19. ?>
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post