note 84699 deleted from book.datetime by danbrown

From: Date: Wed, 24 Jun 2009 16:42:32 +0000
Subject: note 84699 deleted from book.datetime by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-157382@lists.php.net to get a copy of this message
Note Submitter: JonathanCross.com ---- <?php // A demonstration of the new DateTime class and the // fact that it fixes dates before 1970 and after 2038. ?> <h2>PHP 2038 date bug demo (php version <?=phpversion()?>)</h1> <div style='float:left;margin-right:3em;'> <h3>OLD Buggy date()</h3> <? for ( $i = 1900; $i < 2050; $i++) { $datep = "$i-01-01"; print " Trying: $datep ... "; print date("F j, Y", strtotime($datep)); print "<BR>"; } ?></div> <div style='float:left;'> <h3>NEW DateTime Class (v 5.2+)</h3><? for ( $i = 1900; $i < 2050; $i++) { $datep = "$i-01-01"; $date = new DateTime($datep); print " Trying: $datep ... "; print $date->format('F j, Y'); print "<BR>"; } ?></div>

« previous php.notes (#157382) next »