<?php
// result: 07
echo date('m', strtotime('last month'));
echo "\n";
// result: 2022-06-01 07:54:54
// echo date("m",strtotime("-1 month"));
// get start date & last date
$lastmonth = date("M Y", strtotime("-1 month")); // Jun 2022
$timestamp = strtotime('Jul 2022'); // 1656633600
$first_second = date('01/m/Y 00:00:00', $timestamp);
$last_second = date('t/m/Y 23:59:59', $timestamp); // A leap year!
// echo $first_second;
// echo "\n";
// echo $last_second;
echo $first_second;
echo "\n";
echo $last_second;
echo "\n\n";
echo "Ubah tanggal ke unix time stamp:\n";
echo strtotime($first_second);
echo "\n";
echo strtotime($last_second);