如何使用PHP查找一个月中的第一个和最后一个日期?

如何使用PHP查找一个月中的第一个和最后一个日期?例如,今天是2010年4月21日。我想找到2010年4月1日和2010年4月30日。



智慧大石
浏览 389回答 3
3回答

慕容3067478

这将为您提供该月的最后一天:function lastday($month = '', $year = '') {   if (empty($month)) {      $month = date('m');   }   if (empty($year)) {      $year = date('Y');   }   $result = strtotime("{$year}-{$month}-01");   $result = strtotime('-1 second', strtotime('+1 month', $result));   return date('Y-m-d', $result);}第一天:function firstDay($month = '', $year = ''){    if (empty($month)) {      $month = date('m');   }   if (empty($year)) {      $year = date('Y');   }   $result = strtotime("{$year}-{$month}-01");   return date('Y-m-d', $result);} 
打开App,查看更多内容
随时随地看视频慕课网APP