PHP obtient le premier et le dernier jour du mois précédent
date('Y-m-01', strtotime('last month'));
date('Y-m-t', strtotime('last month'));
Abdullah al Mamun
date('Y-m-01', strtotime('last month'));
date('Y-m-t', strtotime('last month'));
$lastDay = date('t',strtotime('last month'));
print_r($lastDay);
$currentMonth = date('M');// if number, then date('m');
//Last month
$lastMonth = Date("F", strtotime("first day of previous month");
$nextMonth = Date("F", strtotime("first day of next month");
$first_day_this_month = date('m-01-Y'); // hard-coded '01' for first day
$last_day_this_month = date('m-t-Y');
$a_date = "2009-11-23";
echo date("Y-m-t", strtotime($a_date));
<?php
// Given a date in string format
$getDate = '2022-01-03';
// Converting string to date
$date = strtotime($getDate);
// Last date of current month.
$lastGetDate = strtotime(date("Y-m-t", $date ));
// Day of the last date
$day = date("l", $lastGetDate);
echo $day;
?>
//Output:
Monday