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
$dates = [
"2020-06-01",
"2020-07-01",
"2020-08-01",
"2020-09-01",
"2021-01-01",
"2022-01-01",
"2022-06-01",
"2022-08-01",
"2022-10-01",
"2023-04-01",
];
$res = array_map(
fn($d) => date('Y-m-d', strtotime("-1 year", strtotime($d))),
$dates
);
print_r($res);