Below is a snippet of code that is part of a much bigger routine, although all I need assistance with is changing the code so it is uses the prior month, or the ability to define the month.
When this executes it adds data to MySQL based the current month, i.e. February but I need to have it also add data (once) for January.
Any help would be great.
$now = new DateTime('now');
$thisYear = $now->format("Y");
$thisMonth = $now->format('m');
$bookingsSql = str_replace('{check_in_year}', $thisYear, $bookingsSql);
$bookingsSql = str_replace('{check_in_month}', $thisMonth, $bookingsSql);
$bookingsSql = str_replace('{check_out_year}', $thisYear, $bookingsSql);
$bookingsSql = str_replace('{check_out_month}', $thisMonth, $bookingsSql);
$bookingsSql = str_replace('{close_date_year}', $thisYear, $bookingsSql);
$bookingsSql = str_replace('{close_date_month}', $thisMonth, $bookingsSql);