- preg_replace_callback: documentation ( source)
- var_export: documentation ( source)
- date: documentation ( source)
- strtotime: documentation ( source)
<?php
$arr = [
"Dec 23 21:37:56 hello",
"Jan 12 02:07:23 hello",
"Jun 3 23:34:34 hello",
"Dec 25 12:47:51 hello"
];
var_export(
preg_replace_callback(
'/^([a-z]{3}) +\d+/i',
function($m) {
static $encounteredJan = false;
$encounteredJan = $encounteredJan || $m[1] === 'Jan';
return date('Y m d', strtotime($m[0] . ($encounteredJan ? '' : ' -1 year')));
},
$arr
)
);