01 - Preheat the oven to 350°F. Line an 8x8-inch baking pan with parchment paper, leaving some overhang for easy removal.
02 - In a medium bowl, whisk together flour, baking powder, baking soda, salt, cinnamon, and nutmeg until well combined.
03 - In a large bowl, whisk brown sugar, granulated sugar, eggs, oil, and vanilla until smooth and fully incorporated.
04 - Fold in the grated carrots, drained pineapple, and nuts if using. Mix until evenly distributed throughout the batter.
05 - Add the dry ingredients to the wet mixture. Stir until just combined, being careful not to overmix. Set aside.
06 - In a separate bowl, beat cream cheese until smooth and creamy. Add sugar, egg, and vanilla. Blend until completely lump-free and well combined.
07 - Spread 2/3 of the carrot cake batter into the prepared pan in an even layer. Pour the cream cheese mixture evenly over the top. Dollop the remaining carrot cake batter over the cream cheese layer.
08 - Use a knife or skewer to gently swirl the batters together, creating a marbled pattern. Be careful not to overmix and lose the distinct layers.
09 - Bake for 38-42 minutes, or until a toothpick inserted in the center comes out mostly clean. The bars should be set but still moist.
10 - Cool completely in the pan. Refrigerate for at least 2 hours to set completely for easier slicing. Cut into bars and serve chilled or at room temperature.