News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Derick Rethans's Blog:
Obtaining the next month in PHP
January 08, 2010 @ 11:35:12

Derick Rethans (master of all things date and time in PHP) has a new post to his blog showing how to correctly get the "next month" since the date string parser doesn't understand how to use that string directly.

Over and over again PHP users complain that next month in PHP's date-string parser doesn't go to the next month, but instead skips to the one after next month.

He describes what happens internally, how PHP bumps up the month and counts the number of days, and how you can use some of newer features in the PHP 5.3 release to get the first day of the next month. Specifically, this means using the "first day of next month" string for the modify() call on the DateTime object. If you're not on PHP 5.3 yet, Derick also includes a method in the comments to do it a slightly different way.

1 comment voice your opinion now!
datetime next month first day


blog comments powered by Disqus

Similar Posts

NetTuts.com: Dates and Time - The OOP Way

XPertDeveloper.com: Is Your PHP Application Affected by the Y2K38?

Phil Sturgeon's Blog: CodeIgniter on PHP 5.3

Wez Furlong\'s Blog: Calling SQLBindParameter and avoiding a datetime overflow.

Davey Shafik\'s Blog: 1st Tampa Bay PHP User Group Meeting!


Community Events

Don't see your event here?
Let us know!


php7 series library interview performance voicesoftheelephpant api install example conference laravel application symfony2 framework opinion podcast release community configure introduction

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework