2000-2069, 70-99 => 1970-1999) $year = (int) $dt->format('Y'); if ($year < 100) { $year += ($year <= 69) ? 2000 : 1900; // Rebuild date with corrected year $month = (int) $dt->format('m'); $day = (int) $dt->format('d'); return sprintf('%04d-%02d-%02d', $year, $month, $day); } return $dt->format('Y-m-d'); } } } // Fallback: strtotime (permissive). If fails, return null. $ts = @strtotime($raw); if ($ts === false) { return null; } return date('Y-m-d', $ts); } }