<?php
$date = new DateTime( '2010-01-31 15:48:21' );
echo $date->modify( 'first day next month' )->format( 'Y-m-d' ), "\n";
?>
Output
2010-03-04
Explanation:
2010-01-31 15:48:21
2010-02-31 15:48:21
"next month" increases month number by 1
2010-03-03 15:48:21
February only has 28 days, so days are overflown
into the next month
2010-03-04 15:48:21
"first day" adds one more day