xxxxxxxxxx
$first_day_this_month = date('m-01-Y'); // hard-coded '01' for first day
$last_day_this_month = date('m-t-Y');
xxxxxxxxxx
date('Y-m-01', strtotime('last month'));
date('Y-m-t', strtotime('last month'));
xxxxxxxxxx
$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");
xxxxxxxxxx
$first = date('Y-m-01', strtotime('last month'));
$last = date('Y-m-t', strtotime('last month'));
xxxxxxxxxx
//get first day of the current month
$start = date("Y-m-1 00:00:00");
//get current date of the month
$end = date("Y-m-d H:i:s");
//query data for the current month so far
$query = $this->db_model->run_query("select column_1, column_2 from table where date_column BETWEEN '".$start."' AND '".$end."'");
xxxxxxxxxx
//Last month
$lastMonth = Date("F", strtotime("first day of previous month");
$nextMonth = Date("F", strtotime("first day of next month");
xxxxxxxxxx
<?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