note 92098 deleted from function.strtotime by thiago

From: Date: Wed, 08 Jul 2009 20:37:25 +0000
Subject: note 92098 deleted from function.strtotime by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-158079@lists.php.net to get a copy of this message
Note Submitter: Rena Kunisaki ---- strtotime() seems to have trouble dealing with large numbers of seconds. <?php echo number_format(strtotime('1000000 seconds') - time()) //outputs 1,000,000 echo number_format(strtotime('10000000 seconds') - time()) //outputs 10,003,600 echo number_format(strtotime('100000000 seconds') - time()) //outputs 100,000,000 echo number_format(strtotime('1000000000 seconds') - time()) //outputs -1,247,084,637 ?> In the second case an extra hour is added out of nowhere. The last case seems unexpected, however 1 billion seconds from now is past Unix timestamp 2,147,483,647, so the calculation overflows. On a 64-bit system I believe this would work correctly.

« previous php.notes (#158079) next »