PHP and Java functions returning different dates when calculating 6 months ahead

I have the following code to calculate what day it will be in 6 months from today.

// Java code
Date currentDate = (new SimpleDateFormat("yyyy-MM-dd")).parse("2024-08-30");
        
Calendar calendar = Calendar.getInstance();
calendar.setTime(currentDate);
calendar.add(Calendar.MONTH, 6);
Date sixMonthsLaterDate = calendar.getTime();
String sixMonthsLaterDateString = new SimpleDateFormat("yyyy-MM-dd").format(sixMonthsLaterDate);

System.out.println("sixMonthsLaterDateString: " + sixMonthsLaterDateString); // returns 2025-02-28

in Java, it returns “2025-02-28”

// PHP code
$currentDate = date_create_from_format('Y-m-d', '2024-08-30');
$sixMonthsLaterDate = $currentDate->modify('+6 month');
$sixMonthsLaterDateString = date_format($sixMonthsLaterDate, 'Y-m-d');
echo "sixMonthsLaterDateString: $sixMonthsLaterDateString"; // returns 2025-03-02

in PHP, it returns “2025-03-02”

Why are they different? Can anyone explain it? Thanks!