---
id: 2157
title: "PHP Date Handling: Subtle Pitfalls Subtracting Months"
source_domain: hackerone.com
source_url: "https://www.hackerone.com/blog/php-date-handling-subtle-pitfalls-subtracting-months"
published_at: "2023-12-08T13:50:43Z"
tags: ["php", "tutorial", "laravel", "coding-pitfalls", "carbon", "date-handling"]
phying_url: "https://phying.com/item/2157"
lang: en
---

# PHP Date Handling: Subtle Pitfalls Subtracting Months

## Summary

Carbon's subMonth() overflows on month-end dates—subtracting a month from December 31st lands on December 1st—so HackerOne recommends startOfMonth() or subMonthNoOverflow() to avoid the surprise.

## Intelligence Metadata

- **Sources:** hackerone.com
- **Published:** 2023-12-08T13:50:43Z
- **Original:** https://www.hackerone.com/blog/php-date-handling-subtle-pitfalls-subtracting-months
- **Phying News:** https://phying.com/item/2157
