Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?php
$year = 2022;
$month = 7;
for($d=1; $d<31; $d++) {
$day_of_week = date('N', strtotime(sprintf("%d-%02d-%02d", $year, $month, $d)));
if ($d == 1) echo str_pad('', ($day_of_week - 1) * 3);
printf("% 3d", $d);
echo ($day_of_week == 7 ? PHP_EOL : '');
}