News Feed
Sections




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

PHPro.org:
Calculate Friday The 13th With Datetime Class
December 01, 2008 @ 08:46:51

As an introduction to the Datetime class functionality PHP 5 has, Kevin Waterson shows how to use it to calculate the "Friday the 13th" for any year.

This class is a request from a PHPRO.ORG regular who asked for a method to calculate Friday the 13th for the next n years. The calculation itself is easy, however, it presents a good opportunity to introduce the PHP datetime class.

He points out that timestamps, because of they way integers are handled, have a somewhat limited lifespan (2038) and dates beyond that cannot be determined by the usual date functions. Instead, he shows how to set up a DateTime object, set a timezone and loop through the days to find the Fridays that land on the 13th.

0 comments voice your opinion now!
tutorial datetime class php5 friday thirteenth


blog comments powered by Disqus

Similar Posts

PHP.net: PHP 5.5.0 Alpha4 released

TechChorus Blog: Create RESTful Applications Using The Zend Framework - Part II: Using HTTP Response

Aaron Wormus' Blog: WS02 at Zend Conf

PHP -GTK Community Site: A New Trio of Posts (phpISO, a PHP-GTK book, and Dev Inspector)

Laracasts: Laravel 5 and Behat: BFFs


Community Events

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


interview framework release wordpress psr7 laravel api series voicesoftheelephpant laravel5 language introduction extension opinion library conference development podcast community unittest

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