note 92098 added to function.strtotime

From: Date: Wed, 08 Jul 2009 20:35:11 +0000
Subject: note 92098 added to function.strtotime
Groups: php.notes 
Request: Send a blank email to php-notes+get-158078@lists.php.net to get a copy of this message
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. ---- Server IP: 72.55.140.6 Probable Submitter: 207.229.58.28 ---- Manual Page -- http://www.php.net/manual/en/function.strtotime.php Edit -- https://master.php.net/note/edit/92098 Del: integrated -- https://master.php.net/note/delete/92098/integrated Del: useless -- https://master.php.net/note/delete/92098/useless Del: bad code -- https://master.php.net/note/delete/92098/bad+code Del: spam -- https://master.php.net/note/delete/92098/spam Del: non-english -- https://master.php.net/note/delete/92098/non-english Del: in docs -- https://master.php.net/note/delete/92098/in+docs Del: other reasons-- https://master.php.net/note/delete/92098 Reject -- https://master.php.net/note/reject/92098 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#158078) next »