note 84701 modified in function.date by danbrown

From: Date: Wed, 22 Oct 2008 14:15:14 +0000
Subject: note 84701 modified in function.date by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-145592@lists.php.net to get a copy of this message
<?php // A demonstration of the new DateTime class for those // trying to use dates before 1970 or after 2038. ?> <h2>PHP 2038 date bug demo (php version <?php echo phpversion(); ?>)</h1> <div style='float:left;margin-right:3em;'> <h3>OLD Buggy date()</h3> <?php $format='F j, Y'; for ( $i = 1900; $i < 2050; $i++) { $datep = "$i-01-01"; ?> Trying: <?php echo $datep; ?> = <?php echo date($format, strtotime($datep)); ?><br> <? } ?></div> <div style='float:left;'> <h3>NEW DateTime Class (v 5.2+)</h3><?php for ( $i = 1900; $i < 2050; $i++) { $datep = "$i-01-01"; $date = new DateTime($datep); ?> Trying: <?php echo $datep; ?> = <?php echo $date->format($format); ?><br> <? } ?></div> --was-- <?php // A demonstration of the new DateTime class for those // trying to use dates before 1970 or after 2038. ?> <h2>PHP 2038 date bug demo (php version <?= phpversion() ?>)</h1> <div style='float:left;margin-right:3em;'> <h3>OLD Buggy date()</h3> <? $format='F j, Y'; for ( $i = 1900; $i < 2050; $i++) { $datep = "$i-01-01"; ?> Trying: <?=$datep?> = <?=date($format, strtotime($datep))?><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); ?> Trying: <?=$datep?> = <?=$date->format($format)?><br> <? } ?></div> http://php.net/manual/en/function.date.php

« previous php.notes (#145592) next »