What are some potential pitfalls when working with dates in PHP, especially when the year is unknown?

When working with dates in PHP, a potential pitfall is handling dates where the year is unknown. To address this, you can use the `DateTime` class in PHP, which allows for flexible date parsing and manipulation. By setting a default year or using a conditional statement to handle cases where the year is missing, you can ensure accurate date processing.

$dateString = "March 15"; // Example date string with unknown year
$defaultYear = 2022; // Set a default year

$date = DateTime::createFromFormat('F d Y', $dateString . ' ' . $defaultYear); // Create DateTime object with default year
if ($date->format('Y') == $defaultYear) {
    // Handle cases where the year was not provided
}

echo $date->format('Y-m-d'); // Output the formatted date